Error on Getting Latest Version after adding new column
gknierim
Posts: 31
I have added a new column to an existing table that does not allow NULL. I have also specified a default value for the column. However, when the other developers try to get latest, they are getting the following error:
Cannot insert the value NULL into column 'DataSourceID', table 'Fikes.SkylineSP.tmp_rg_xx_dm_Current_CompetitorPriceHistory_Daily'; column does not allow nulls. INSERT fails.
I saw a post from Dec 2010 that said my options were to clear out the table of data or manually add the column and the default value.
Is there a better way to fix this problem now with Migrations scripts somehow?
Thanks,
Greg
Cannot insert the value NULL into column 'DataSourceID', table 'Fikes.SkylineSP.tmp_rg_xx_dm_Current_CompetitorPriceHistory_Daily'; column does not allow nulls. INSERT fails.
I saw a post from Dec 2010 that said my options were to clear out the table of data or manually add the column and the default value.
Is there a better way to fix this problem now with Migrations scripts somehow?
Thanks,
Greg
Comments
I found out that even though the Migration script is created, it is not run when a Get Latest is executed. Is this correct?
We ended up running the migration script manually and then doing a Get Latest worked on the remaining objects.
Seems to me that SQL Source Control should know what revision you are on, and look for the migration scripts to run and run them automatically. If it is supposed to do this, then what am I doing wrong?
Also, it would be nice if I could run the Migration script from somewhere instead of editing it, copying all of the text and then pasting it in a separate window.
Thanks,
Greg
Also, it's possible that only once you set up this migrations folder the revision extended property gets written to your database. This is what is used to determine which migration scirpts get picked up, so if you set up migrations on machines after you've added a new migration script, it won't work the first time because the extended property won't be there.
David Atkinson
Red Gate
Product Manager
Redgate Software
My order of events were this: Made the schema change and checked it in. Setup the Migrations folder and created a script pointing to that revision. Then, I had the other developer setup his migrations folder and do a get latest. If I did something out of sequence let me know. I don't have an immediate need to to do another script so maybe it will work next time.
Product Manager
Redgate Software
Could you try using SQL Compare to deploy from source control to a new database (empty) to check that this picks up the migration script?
Product Manager
Redgate Software
It could very well be that the revision that the database was at was later than the revision that I made the migration script for since there was additional revisions after the one I needed the script for. I did not check the revision number before the get latest was attempted.
SQL Compare has a fully functional 14-day trial and is a useful tool for troubleshooting. If it picks up migrations scripts, they will be displayed in the comparison results screen with a different icon against the changes.
Product Manager
Redgate Software
Needless to say, we ran it manually, and everything else worked so we are ok and now know for next time.
Do let us know if this doesn't work next time as we'd like to work with you to resolve this.
Product Manager
Redgate Software