SQL Change Automation in SSMS

Apply changes to a database

Apply changes to database allows you to keep your development database up-to-date by running any Migration scripts in the SQL Change Automation Project that haven’t yet been applied to the database.

1. Use Migrations to navigate to see the project scripts view. Right click on a folder and select Add Migration


2. Copy the following code into the new script.  Make sure you do not remove the Migration ID header.

CREATE TABLE dbo.tblTest
(
	ID     INT    NOT NULL PRIMARY KEY,
	Name VARCHAR(50) NULL
)



3. Click Save.  This saves the file to the project, but no changes have been made to the database yet.


4. Get back to the SQL Change Automation window and open the Overview. Then navigate to the Apply to database page.


5. This will show you all the Migration scripts that are in the SQL Change Automation Project that haven’t been applied to the database yet.  It also shows you any changes to Programmable Objects that need updating.


6. Clicking on the blue file name will open it in a new query window if you want to look at the script.


7. The script status can be altered to mark scripts as applied using the drop-down next to each script.


8. Click Apply in the top right.  This will actually run the pending scripts on your development database that was set in the connection above.


9. After the apply completes, you’ll see a success message.


If you refresh your database in the SSMS Object Explorer, your changes will now appear.


Handling changes in a migration script which have already been applied to a database


If you have a migration script which only contains changes which have already been applied to the database without applying or deploying to that database via SQL Change Automation, then it can be marked as applied.

This will update the record of which scripts have been run inside the SQL Change Automation __MigrationLog table within the development database, without executing that script against the database.

This can be achieved by navigating to the Apply screen and selecting Applied from the dropdown.

Please note that this action should not be required if you are using SQL Change Automation via a standard workflow.  It is mainly a tool for resolving error scenarios.



Didn't find what you were looking for?