Https://documentation.red-gate.com/display/SOC5/SQL+Source+Control+5+documentation
Working with migration scriptswhat is migration scripts?
To deploy changes from version control, the SQL Compare engine generates a deployment script. This was based on the differences between the state in version control and the target database. Migration scripts in version control can define what the SQL Compare engine generates specific sections of this deployment Script.
Migration scripts is necessary to avoid data loss when making certain schema changes. To achieve this, the migration script intervenes to make data changes occur at the right point of the deployment.
In most cases, you are need to write SQL for the data changes in the migration script. Schema changes is committed separately and deployed as normal.
To learn more, see migration script examples.
Deploying Migration Scripts
SQL Compare One or later can generate deployment scripts with migrations using the following source/target types:
Source:
- Scripts folder
- Source Control
Target:
- Live Database
- Scripts folder
We recommend using SQL Compare to deploy changes to production, as you had the opportunity to review the deployment scrip T before it ' s deployed. For a full walkthrough of the deployment process using SQL Compare, see Migration script examples.
It is possible to use the Get latest function in SQL Source Control to deploy these changes, however we don ' t rec Ommend linking your production database directly to source control.
Dependencies
When you create a migration script the includes uncommitted schema changes, SQL Source Control automatically includes any Dependencies. Deselecting any of these dependencies during the deployment stage would cause the deployment to fail.
Static data
Migration scripts do not work with static data. See Static data and migrations.
Deploy a database from source control
To deploy a database from source control to a server, use SQL Compare Pro, or the SQL Server Management Studio integration Pack add-in.
Deploying with SQL Compare
To deploy with SQL Compare:
- Open SQL Compare.
- Select a version from source control.
For full instructions, "Selecting a version from source control" on the Setting Data sources page (SQL Compare Documentati ON).
- Run the comparison.
- Open the Deployment Wizard and deploy the version.
For full instructions, see Deploying Data Sources (SQL Compare documentation).
SQL Source Control