SQLCompare updating column with FK to new table

Associate
Joined
23 Apr 2008
Posts
232
Hi Guys

We use RedGate SQLCompare over the cmd line to update our databases everyday.

Ive added a column to an existing table that doesn't allow nulls and has a default value of 1.

The FK for this column is to a new lookup table with static data.

When SQLCompare updates our database it tries to add the column and default value before adding the new lookup table and so the FK breaks and the update fails :(

Anyone have any experience with this?

Is some kind of pre migration the only way around this? :(

thanks!
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
15,412
Location
The land of milk & beans
This is a common problem with RedGate tools. The RedGate SQL source control software has the same issue of trying to create the FK constraint on an existing table, before the new static data has been inserted.

Redgates support are ******* useless 90% of the time, so we end up fixing it ourselves manually. Usually creating a new DB alongside the existing, importing data into that, writing some SQL to copy the data over, then run the SQLCompare to add the FK.
 
Associate
OP
Joined
23 Apr 2008
Posts
232
I managed to get it to work by calling the sqlcompare software twice...

Once with the /IgnoreKeys cmd switch to get just the new schema without FK's

Then another call normally to get the FK's back

This seems to fix it but means i have to call it twice :(
 
Back
Top Bottom