Options

Committing migration scripts

I am having difficult figuring our migration scripts. (new user of SQL Source Control)

Please see image:
j4x5940kyyz7.png

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

  • Options
    Hi,

    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"

    7x5wmjs0xuha.png

    Then the table will appear under the migration script, and will not show any warnings.
    Peter Gerrard

    Software Engineer
    Redgate Software
  • Options
    Thanks @PeterG . I actually tried both script types but I totally missed the fact you need to select the table first - and then put in your script. Makes perfect sense now. Thanks so much for helping out!
Sign In or Register to comment.