Why is migration script no longer being used for deployment
mjashton
Posts: 10 New member
in SQL Compare
Our Source Control has a single migration script, created to handle the change of data-type to a field in a single table. Initially when using SQL Compare to create deployment scripts this migration script was detected and used, but recently it has stopped being used and so the creation of a deployment script fails and we have to manually intervene and recreate the 'fix' contained within the migration script every time. This obviously isn't great from an automation viewpoint.
I'm not finding any clues as to why the migration script is no longer being used, but did wonder if it was because there are now new dependencies/constraints linked to the altered table which aren't covered by the old migration script? If so, is it possible to change the migration script, or force it to be recreated?
Or maybe I'm barking up the wrong tree and the problem is something else.
I'm not finding any clues as to why the migration script is no longer being used, but did wonder if it was because there are now new dependencies/constraints linked to the altered table which aren't covered by the old migration script? If so, is it possible to change the migration script, or force it to be recreated?
Or maybe I'm barking up the wrong tree and the problem is something else.
Tagged:
Comments
See https://documentation.red-gate.com/display/SOC5/RedGateLocal.DeploymentMetadata for more details on that table, and Working with migration scripts for general information about how the migrations feature works.
Redgate Software
I believe in this scenario, whether the migration script has been run or not is reset each time with the restore of the db BAK?
I've attempted to edit the migration script (Migrations > Existing migration scripts > view/edit) to include the new dependencies that need dropping/adding before changing the table.
I've added the appropriate changes and clicked the 'save and close' button on the migration script, and it now appears within the 'commit' tab as something new to save to source control. However when I attempt to 'save changes' it Errors with
The script definitely appears in the 'Existing migration scripts' section, but maybe this is pointing to why it is no longer being used when creating a deployment script using SQL Compare? Has something become corrupt, and if so what is the best way to correct this.
The intended workflow is that you commit your changes as normal. If you need to make a change that requires a migration because the Compare engine would normally lose data (like your example of changing a data type with an incompatible type), then instead of committing your change, commit a migration script that covers that change (the documentation has an example of renaming a table). You then proceed as normal until the next time you need to make such a change, at which point you add another migration script (not editing the first migration script).
As for what's become corrupted in this case, you should start by looking in the Custom Scripts folder, which is where the migration scripts and their associated metadata is stored, and in particular at the DeploymentOrder.json file which links the scripts together. That's described in the documentation (How migration scripts work). If you can't work out what's wrong, we'd probably need a copy of your scripts folder to diagnose the problem, in which case emailing support@red-gate.com would be the best way forward.
Redgate Software