Committing migration scripts
Kazoo60
Posts: 7 Bronze 2
I am having difficult figuring our migration scripts. (new user of SQL Source Control)
Please see image:
I added a column to an existing table (nullable), the populated it. Afterward I then set the column to not null and re-positioned it in the column order of the table. I also created a view that uses the new column.
Next, I attempted to commit the changes. In response to the warning that came up regarding my adding a not-null column, I added a migration script to add the new column and to populate it as I had done on my local instance.
Even though I added the migration script, I still get the warning as shown. I don't seem to be able to commit the igration script and table at the same time even though the documentation says the migration will run first. I do, however, seem to be able to commit the table change on its own which would surely fail. Confused. Am I doing something wrong?
Thanks
Please see image:
I added a column to an existing table (nullable), the populated it. Afterward I then set the column to not null and re-positioned it in the column order of the table. I also created a view that uses the new column.
Next, I attempted to commit the changes. In response to the warning that came up regarding my adding a not-null column, I added a migration script to add the new column and to populate it as I had done on my local instance.
Even though I added the migration script, I still get the warning as shown. I don't seem to be able to commit the igration script and table at the same time even though the documentation says the migration will run first. I do, however, seem to be able to commit the table change on its own which would surely fail. Confused. Am I doing something wrong?
Thanks
Tagged:
Comments
Your issue is you are doing a data only migration instead of a schema change migration. When you go to the Migrations tab you want to select the table in the "Replace uncommitted schema changes" instead of "Start with blank script"
Then the table will appear under the migration script, and will not show any warnings.
Software Engineer
Redgate Software