Migrations v 2 Source Target Migrations v 2

  • Slides: 9
Download presentation
Migrations v 2 Source Target

Migrations v 2 Source Target

Migrations v 2 Source Target Version Script 1 … 2 … 3 … 4

Migrations v 2 Source Target Version Script 1 … 2 … 3 … 4 …

Migrations v 2 Source 1. Deploy and execute migration scripts Target Version Script 1

Migrations v 2 Source 1. Deploy and execute migration scripts Target Version Script 1 … 2 … 3 … 4 … Step 1

Migrations v 2 Source 1. Deploy and execute migration scripts Target Step 2 Version

Migrations v 2 Source 1. Deploy and execute migration scripts Target Step 2 Version Script 1 … 2 … 3 … 4 … Step 1 2. Use SQL Compare to deploy remaining changes

Migrations v 2 BEGIN TRANSACTION Source 1. Deploy and execute migration scripts Target Step

Migrations v 2 BEGIN TRANSACTION Source 1. Deploy and execute migration scripts Target Step 2 Version Script 1 … 2 … 3 … 4 … Step 1 2. Use SQL Compare to deploy remaining changes COMMIT TRANSACTION

Migrations v 2 Example migration script IF some condition BEGIN EXEC some script END

Migrations v 2 Example migration script IF some condition BEGIN EXEC some script END

Migrations v 2 Example migration script (renaming My. Table to My. Table 2) DECLARE

Migrations v 2 Example migration script (renaming My. Table to My. Table 2) DECLARE @Should. Run. Migration. Script BIT SET @Should. Run. Migration. Script = 1 IF (old dbo. My. Table does not exist) BEGIN SET @Should. Run. Migration. Script = 0; END IF @Should. Run. Migration. Script = 1 BEGIN EXEC sp_rename END

Migrations v 2 Example migration script (renaming My. Table to My. Table 2) DECLARE

Migrations v 2 Example migration script (renaming My. Table to My. Table 2) DECLARE @Should. Run. Migration. Script BIT SET @Should. Run. Migration. Script = 1 IF NOT EXISTS (SELECT 1 FROM [information_schema]. [Tables] WHERE table_schema = 'dbo' AND TABLE_NAME = ‘My. Table') BEGIN SET @Should. Run. Migration. Script = 0; PRINT 'Object ''[dbo]. [My. Table]'' could not be found - skipping migration. '; END IF @Should. Run. Migration. Script = 1 BEGIN EXEC sp_rename '[dbo]. [My. Table]', 'My. Table 2' END

Migrations v 2 BEGIN TRANSACTION Source 1. Deploy and execute migration scripts Target Step

Migrations v 2 BEGIN TRANSACTION Source 1. Deploy and execute migration scripts Target Step 2 Version Script 1 … 2 … 3 … 4 … Step 1 2. Use SQL Compare to deploy remaining changes COMMIT TRANSACTION