Skip to content

Commit 62e30a4

Browse files
authored
Update GenerateMigration.ps1
updated to latest flyway CLI syntax and added comments
1 parent cfb6f45 commit 62e30a4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Helpers/GenerateMigration.ps1

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
# Define base path
2-
# $basePath = "C:\WorkingFolders\FWD\<projectRoot>"
3-
$basePath = Get-Location
1+
$projectPath = "C:\WorkingFolders\FWD\NewWorldDB" # Get-Location for current dir
42

5-
# Define variables for paths
6-
$flywayTomlPath = Join-Path $basePath "flyway.toml"
7-
$deploymentDeltasPath = Join-Path $basePath "deploymentDeltas.zip"
8-
$outputFolderPath = Join-Path $basePath "migrations"
3+
#source of Changes eg. Shared Dev environment
4+
$sourceUrl = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true"
95

10-
# Diff between SchemaModel and Migrations using Shadow defined in the flyway.toml
11-
flyway-dev diff -p $flywayTomlPath --i-agree-to-the-eula --from=SchemaModel --to=Migrations -a $deploymentDeltasPath
6+
#scratch DB to allow flyway to use to generate a new script - can provide a backup file that flyway will rehydrate on the specified URL or existing empty db to build entirly from code eg. 1__Baseline.sql to 1+n__current_version.sql
7+
$buildUrl = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Shadow;encrypt=false;integratedSecurity=true;trustServerCertificate=true"
128

13-
# Take and generate migrations
14-
flyway-dev take -p $flywayTomlPath -a $deploymentDeltasPath --i-agree-to-the-eula | flyway-dev generate -p $flywayTomlPath -a $deploymentDeltasPath --i-agree-to-the-eula --outputFolder=$outputFolderPath
9+
#the Description of the migration script generated - should probably include feature/ticket information
10+
$scriptName = "YourNewMigrationDescription"
11+
12+
#Syncs the Schema Model folder with the provided Source URL
13+
flyway diff model "-workingDirectory=$projectPath" "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$sourceUrl"
14+
#Generated a new migration script by comparing the Schema Model folder to Build Url after it's been brought to current version.
15+
flyway diff generate "-workingDirectory=$projectPath" "-diff.source=schemaModel" "-diff.target=migrations" "-generate.types=versioned,undo" "-generate.description=$scriptName" "-diff.buildEnvironment=shadow" "-environments.shadow.url=$buildUrl"

0 commit comments

Comments
 (0)