1. 程式人生 > >SQL Source Control

SQL Source Control

view tle work sin script direct man ins soc

https://documentation.red-gate.com/display/SOC5/SQL+Source+Control+5+documentation

Working with migration scripts

What are migration scripts?

To deploy changes from version control, the SQL Compare engine generates a deployment script. This is based on the differences between the state in version control and the target database. Migration scripts in version control can define how the SQL Compare engine generates specific sections of this deployment script.

Migration scripts are 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 only need to write SQL for the data changes in the migration script. Schema changes are committed separately and deployed as normal.

To learn more, see Migration script examples.

Deploying migration scripts

SQL Compare 11 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 have the opportunity to review the deployment script 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 recommend linking your production database directly to source control.

Dependencies

When you create a migration script that includes uncommitted schema changes, SQL Source Control automatically includes any dependencies. Deselecting any of these dependencies during the deployment stage will 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:

    1. Open SQL Compare.
    2. Select a version from source control.
      For full instructions, "Selecting a version from source control" on the Setting data sources page (SQL Compare documentation).
    3. Run the comparison.
    4. Open the Deployment Wizard and deploy the version.
      For full instructions, see Deploying data sources (SQL Compare documentation).

SQL Source Control