From 06338354ee65640ad57ecf408bd0d91ff6bb81e3 Mon Sep 17 00:00:00 2001 From: turimbar1 Date: Sun, 7 Dec 2025 15:58:18 -0800 Subject: [PATCH 01/11] started Adding backups as baseline --- Helpers/projectInitCompareOptions.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Helpers/projectInitCompareOptions.ps1 b/Helpers/projectInitCompareOptions.ps1 index ffea4c7..ac5a523 100644 --- a/Helpers/projectInitCompareOptions.ps1 +++ b/Helpers/projectInitCompareOptions.ps1 @@ -2,15 +2,16 @@ $databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql $Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" $User = "" $Password = "" + $projectName = "Autobaseline" $projectPath = "." +$backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak # Set the schemas value $Schemas = @("") # can be empty for SqlServer flyway auth -IAgreeToTheEula -startEnterpriseTrial -$ErrorActionPreference = 'Break' flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" if ($LASTEXITCODE -ne 0) { exit 1 @@ -24,6 +25,13 @@ mkdir $projectName cd ./$projectName flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" +if ($backupPath -ne "") { + <# Action to perform if the condition is true #> + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.shadow]`nurl = `"jdbc:sqlserver://localhost;databaseName=NorthByNorthwestWind_dev_shadow;encrypt=optional;integratedSecurity=true;trustServerCertificate=true`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" + ) +} + <# ## Modify flyway.toml to adjust comparison options (Get-Content -Path "flyway.toml") ` -replace 'ignorePermissions\s*=\s*false', 'ignorePermissions = true' ` From 7d3d429548bf475bfa53f12760c45d5912c7937f Mon Sep 17 00:00:00 2001 From: turimbar1 Date: Sun, 7 Dec 2025 16:31:56 -0800 Subject: [PATCH 02/11] adjusting backups as baselines --- Helpers/projectInitCompareOptions.ps1 | 69 +-------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/Helpers/projectInitCompareOptions.ps1 b/Helpers/projectInitCompareOptions.ps1 index ac5a523..b7dba62 100644 --- a/Helpers/projectInitCompareOptions.ps1 +++ b/Helpers/projectInitCompareOptions.ps1 @@ -1,68 +1 @@ -$databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql -$Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" -$User = "" -$Password = "" - -$projectName = "Autobaseline" -$projectPath = "." -$backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak - -# Set the schemas value -$Schemas = @("") # can be empty for SqlServer - - -flyway auth -IAgreeToTheEula -startEnterpriseTrial -flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" -if ($LASTEXITCODE -ne 0) { - exit 1 -} - -if (Test-Path -Path "$projectPath\$projectName") { - Remove-Item -Path $projectName -Recurse -Force -} -cd $projectPath -mkdir $projectName -cd ./$projectName -flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" - -if ($backupPath -ne "") { - <# Action to perform if the condition is true #> - (Add-Content -Path "flyway.toml" ` - -Value "`n`n[environments.shadow]`nurl = `"jdbc:sqlserver://localhost;databaseName=NorthByNorthwestWind_dev_shadow;encrypt=optional;integratedSecurity=true;trustServerCertificate=true`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" - ) -} - -<# ## Modify flyway.toml to adjust comparison options -(Get-Content -Path "flyway.toml") ` --replace 'ignorePermissions\s*=\s*false', 'ignorePermissions = true' ` --replace 'ignoreUsersPermissionsAndRoleMemberships\s*=\s*false', 'ignoreUsersPermissionsAndRoleMemberships = true' ` --replace 'includeDependencies\s*=\s*true', 'includeDependencies = false' | -Set-Content -Path "flyway.toml" - -# Define the file path -$filePath = "Filter.scpf" - -# Check if the file exists -if (Test-Path -Path $filePath) { - # Load the XML file - $xml = [xml](Get-Content -Path $filePath) - - # Find the element and update its child nodes - $noneElement = $xml.NamedFilter.Filter.Filters.None - $noneElement.Include = "False" - $noneElement.Expression = "((@SCHEMA LIKE 'cdc%'))" - - - $currentPath = Get-Location - $filePath = Join-Path -Path $currentPath -ChildPath $filePath - # Save the updated XML back to the file - $xml.Save($filePath) - Write-Host "Filter.scpf updated successfully." -} else { - Write-Host "Filter.scpf does not exist." -} -#> - -flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$Url" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" -flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" -cd .. \ No newline at end of file +-diff.buildEnvironmen \ No newline at end of file From f3c2eef8aeec875a8a1c023364fac5f7276edae0 Mon Sep 17 00:00:00 2001 From: turimbar1 Date: Sun, 7 Dec 2025 20:45:33 -0800 Subject: [PATCH 03/11] ffd --- Helpers/projectInitCompareOptions.ps1 | 77 ++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/Helpers/projectInitCompareOptions.ps1 b/Helpers/projectInitCompareOptions.ps1 index b7dba62..2059ca4 100644 --- a/Helpers/projectInitCompareOptions.ps1 +++ b/Helpers/projectInitCompareOptions.ps1 @@ -1 +1,76 @@ --diff.buildEnvironmen \ No newline at end of file +$databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql +# connection string to prodlike database +$Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" +$User = "" +$Password = "" +$databaseName = ($Url -split "databaseName=")[1] -split ";|$" | Select-Object -First 1 +$projectName = "$databaseName" +$projectPath = "." +# Backup as Baseline path - must be accessible by DB server - leave empty if not needed +$backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak + +# Set the schemas value +$Schemas = @("") # can be empty for SqlServer + + +flyway auth -IAgreeToTheEula -startEnterpriseTrial +flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" +if ($LASTEXITCODE -ne 0) { + exit 1 +} + +if (Test-Path -Path "$projectPath\$projectName") { + Remove-Item -Path $projectName -Recurse -Force +} +cd $projectPath +mkdir $projectName +cd ./$projectName +flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" + +if ($backupPath -ne "") { + $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' + $Url = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.shadow]`nurl = `"$Url`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" + ) +} + +<# ## Modify flyway.toml to adjust comparison options +(Get-Content -Path "flyway.toml") ` +-replace 'ignorePermissions\s*=\s*false', 'ignorePermissions = true' ` +-replace 'ignoreUsersPermissionsAndRoleMemberships\s*=\s*false', 'ignoreUsersPermissionsAndRoleMemberships = true' ` +-replace 'includeDependencies\s*=\s*true', 'includeDependencies = false' | +Set-Content -Path "flyway.toml" + +# Define the file path +$filePath = "Filter.scpf" + +# Check if the file exists +if (Test-Path -Path $filePath) { + # Load the XML file + $xml = [xml](Get-Content -Path $filePath) + + # Find the element and update its child nodes + $noneElement = $xml.NamedFilter.Filter.Filters.None + $noneElement.Include = "False" + $noneElement.Expression = "((@SCHEMA LIKE 'cdc%'))" + + + $currentPath = Get-Location + $filePath = Join-Path -Path $currentPath -ChildPath $filePath + # Save the updated XML back to the file + $xml.Save($filePath) + Write-Host "Filter.scpf updated successfully." +} else { + Write-Host "Filter.scpf does not exist." +} +#> + +if ($backupPath -eq "") { + flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$Url" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" + flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" +} else { + Write-Output "Restoring provided backup file to server URL and Populating SchemaModel from it" + flyway diff model "-diff.source=migrations" "-diff.target=schemaModel" "-diff.buildEnvironment=shadow" +} +cd .. \ No newline at end of file From 3618820eb8fdc1ea22aecb96e9b3c3ea25e801cf Mon Sep 17 00:00:00 2001 From: turimbar1 Date: Mon, 8 Dec 2025 10:52:39 -0800 Subject: [PATCH 04/11] Added comments --- Helpers/projectInitCompareOptions.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Helpers/projectInitCompareOptions.ps1 b/Helpers/projectInitCompareOptions.ps1 index 2059ca4..e170bbd 100644 --- a/Helpers/projectInitCompareOptions.ps1 +++ b/Helpers/projectInitCompareOptions.ps1 @@ -1,3 +1,4 @@ +# Set parameters $databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql # connection string to prodlike database $Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" @@ -12,13 +13,14 @@ $backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSS # Set the schemas value $Schemas = @("") # can be empty for SqlServer - +# Start Flyway Enterprise Trial and test connection flyway auth -IAgreeToTheEula -startEnterpriseTrial flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" if ($LASTEXITCODE -ne 0) { exit 1 } +# Initialize project - create folders and flyway.toml - delete existing project folder if exists if (Test-Path -Path "$projectPath\$projectName") { Remove-Item -Path $projectName -Recurse -Force } @@ -28,6 +30,7 @@ cd ./$projectName flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" if ($backupPath -ne "") { + # Add shadow environment to flyway.toml $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' $Url = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" (Add-Content -Path "flyway.toml" ` @@ -35,7 +38,7 @@ if ($backupPath -ne "") { ) } -<# ## Modify flyway.toml to adjust comparison options +<# # Modify flyway.toml to adjust comparison options (Get-Content -Path "flyway.toml") ` -replace 'ignorePermissions\s*=\s*false', 'ignorePermissions = true' ` -replace 'ignoreUsersPermissionsAndRoleMemberships\s*=\s*false', 'ignoreUsersPermissionsAndRoleMemberships = true' ` @@ -66,6 +69,7 @@ if (Test-Path -Path $filePath) { } #> +# Populate SchemaModel from dev database or from backup if ($backupPath -eq "") { flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$Url" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" From 48c5ddb2583fc18a8de45dd1aa94c2952daea99f Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Mon, 8 Dec 2025 14:31:41 -0600 Subject: [PATCH 05/11] project init with bash --- Helpers/projectInitCompareOptions.sh | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Helpers/projectInitCompareOptions.sh diff --git a/Helpers/projectInitCompareOptions.sh b/Helpers/projectInitCompareOptions.sh new file mode 100644 index 0000000..4205f41 --- /dev/null +++ b/Helpers/projectInitCompareOptions.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Set parameters +DATABASE_TYPE="SqlServer" # alt values: SqlServer Oracle PostgreSql MySql +# connection string to prodlike database +URL="jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" +USER="" +PASSWORD="" +DATABASE_NAME=$(echo "$URL" | sed -n 's/.*databaseName=\([^;]*\).*/\1/p') +PROJECT_NAME="$DATABASE_NAME" +PROJECT_PATH="." +# Backup as Baseline path - must be accessible by DB server - leave empty if not needed +BACKUP_PATH="/var/opt/mssql/backup/Northwind.bak" # eg /var/opt/mssql/backup/Northwind.bak + +# Set the schemas value +SCHEMAS="" # can be empty for SqlServer + +# Start Flyway Enterprise Trial and test connection +flyway auth -IAgreeToTheEula -startEnterpriseTrial +flyway testConnection "-url=$URL" "-user=$USER" "-password=$PASSWORD" "-schemas=$SCHEMAS" +if [ $? -ne 0 ]; then + exit 1 +fi + +# Initialize project - create folders and flyway.toml - delete existing project folder if exists +if [ -d "$PROJECT_PATH/$PROJECT_NAME" ]; then + rm -rf "$PROJECT_PATH/$PROJECT_NAME" +fi +cd "$PROJECT_PATH" +mkdir "$PROJECT_NAME" +cd "./$PROJECT_NAME" +flyway init "-init.projectName=$PROJECT_NAME" "-init.databaseType=$DATABASE_TYPE" + +if [ -n "$BACKUP_PATH" ]; then + # Add shadow environment to flyway.toml + SHADOW_DATABASE_NAME="${DATABASE_NAME}_${USER}_shadow" + SHADOW_URL=$(echo "$URL" | sed "s/databaseName=[^;]*/databaseName=$SHADOW_DATABASE_NAME/") + cat >> "flyway.toml" << EOF + + +[environments.shadow] +url = "$SHADOW_URL" +provisioner = "backup" + +[environments.shadow.resolvers.backup] +backupFilePath = "$BACKUP_PATH" +backupVersion = "000" + + [environments.shadow.resolvers.backup.sqlserver] + generateWithMove = true +EOF +fi + +<< 'COMMENT' +# Modify flyway.toml to adjust comparison options +sed -i 's/ignorePermissions\s*=\s*false/ignorePermissions = true/' "flyway.toml" +sed -i 's/ignoreUsersPermissionsAndRoleMemberships\s*=\s*false/ignoreUsersPermissionsAndRoleMemberships = true/' "flyway.toml" +sed -i 's/includeDependencies\s*=\s*true/includeDependencies = false/' "flyway.toml" + +# Define the file path +FILE_PATH="Filter.scpf" + +# Check if the file exists +if [ -f "$FILE_PATH" ]; then + # Update the XML file using sed or xmlstarlet (requires xmlstarlet installed) + # Using sed for basic XML manipulation + sed -i '//,/<\/None>/ { + s|.*|False| + s|.*|((@SCHEMA LIKE '\''cdc%'\''))| + }' "$FILE_PATH" + + echo "Filter.scpf updated successfully." +else + echo "Filter.scpf does not exist." +fi +COMMENT + +# Populate SchemaModel from dev database or from backup +if [ -z "$BACKUP_PATH" ]; then + flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$URL" "-environments.dev.user=$USER" "-environments.dev.password=$PASSWORD" "-environments.dev.schemas=$SCHEMAS" + flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" +else + echo "Restoring provided backup file to server URL and Populating SchemaModel from it" + flyway diff model "-diff.source=migrations" "-diff.target=schemaModel" "-diff.buildEnvironment=shadow" +fi +cd .. From cdc8a19a5363cfc2baf2e4547994bffa65d7635f Mon Sep 17 00:00:00 2001 From: turimbar1 Date: Mon, 8 Dec 2025 22:10:27 -0800 Subject: [PATCH 06/11] POC environment setup walkthrough added --- Helpers/projectInitCompareOptions.ps1 | 80 ++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/Helpers/projectInitCompareOptions.ps1 b/Helpers/projectInitCompareOptions.ps1 index e170bbd..3dc4bcc 100644 --- a/Helpers/projectInitCompareOptions.ps1 +++ b/Helpers/projectInitCompareOptions.ps1 @@ -32,9 +32,9 @@ flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" if ($backupPath -ne "") { # Add shadow environment to flyway.toml $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' - $Url = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" + $shadowUrl = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" (Add-Content -Path "flyway.toml" ` - -Value "`n`n[environments.shadow]`nurl = `"$Url`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" + -Value "`n`n[environments.shadow]`nurl = `"$shadowUrl`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" ) } @@ -77,4 +77,80 @@ if ($backupPath -eq "") { Write-Output "Restoring provided backup file to server URL and Populating SchemaModel from it" flyway diff model "-diff.source=migrations" "-diff.target=schemaModel" "-diff.buildEnvironment=shadow" } + +$pocSetupMessage = "`nYDo you want to set up a full POC environment with dev and test databases?" +if ($backupPath -ne "") { + $pocSetupMessage += " $backupPath WILL BE RESTORED multiple times to provided instance for dev and test databases. (Y/N)?" +} else { + $pocSetupMessage += "Provided database is assumed as test and new dev database WILL BE CREATED (Y/N)?" +} + +# Interactive prompt for full POC environment setup +$response = Read-Host $pocSetupMessage +if ($response -eq "Y" -or $response -eq "y") { + Write-Host "Setting up full POC environment..." + if ($backupPath -eq "") { + $devDatabaseName = $databaseName + '_dev' + $devUrl = $Url -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"create-database`"" + ) + Write-Host "Creating dev database $devDatabaseName and running Baseline script to populate it..." + flyway migrate -environment=development + + } else { + $devDatabaseName = $databaseName + '_dev' + $devUrl = $Url -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"backup`"`n`n[environments.development.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.development.resolvers.backup.sqlserver]`n generateWithMove = true" + ) + $testDatabaseName = $databaseName + '_test' + $testUrl = $Url -replace "databaseName=[^;]*", "databaseName=$testDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.test]`nurl = `"$testUrl`"`nprovisioner = `"backup`"`n`n[environments.test.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.test.resolvers.backup.sqlserver]`n generateWithMove = true" + ) + Write-Host "Restoring backup file to create dev database $devDatabaseName" + flyway migrate -environment=development + Write-Host "Restoring backup file to create test database $testDatabaseName" + flyway migrate -environment=test + } + Write-Host "POC environment setup completed." + $skipped = $false + +} else { + Write-Host "Just showing flyway commands with documentation links to run manually" + $skipped = $true +} + +$sqlTablescript = " + CREATE TABLE AA_Test_Parent ( + ParentID INT PRIMARY KEY, + ParentName NVARCHAR(100) NOT NULL +); + +CREATE TABLE AA_Test_Child ( + ChildID INT PRIMARY KEY, + ChildName NVARCHAR(100) NOT NULL, + ParentID INT, + FOREIGN KEY (ParentID) REFERENCES AA_Test_Parent(ParentID) ON DELETE CASCADE +);" +# Interactive prompt for full POC environment setup +$runForMe = Read-Host "Use this script to create a sample migration - $sqlTablescript `n should I run this for you (Y)?`n Or do you want to run them yourself (N)?" +if ($runForMe -eq "Y" -or $runForMe -eq "y" -and -not $skipped) { + Write-Host "Creating sample tables in dev database..." + flyway migrate "-initSql=$sqlTablescript" "-url=$devUrl" "-user=$User" "-password=$Password" + Write-Host "Sample tables created in dev database." + $runScriptsForMe = $true +} else { + $response = Read-Host "Skipping sample table creation. Have you run them yourself against $devDatabaseName? (Y/N)?" +} +if ( $runForMe -eq "Y" -or $runForMe -eq "y" -or $response -eq "y" -or $response -eq "Y" -and -not $skipped) { + Write-Host "Creating migration scripts based on changes from dev to test database..." + flyway diff model "-diff.source=development" "-diff.target=schemaModel" + flyway diff generate "-diff.source=schemaModel" "-diff.target=migrations" "-generate.types=versioned,undo" "-diff.buildEnvironment=shadow" + Write-Host "Migration scripts created." +} else { + Write-Host "Skipping migration script creation." + +} cd .. \ No newline at end of file From 51e19b9dc3f8b69187b166593fcbedaad1e69dcf Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Tue, 9 Dec 2025 08:26:38 -0600 Subject: [PATCH 07/11] move and rename poc runtime book --- .../fullFlywayPOCSetupAndRun.ps1 | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 diff --git a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 new file mode 100644 index 0000000..e170bbd --- /dev/null +++ b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 @@ -0,0 +1,80 @@ +# Set parameters +$databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql +# connection string to prodlike database +$Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" +$User = "" +$Password = "" +$databaseName = ($Url -split "databaseName=")[1] -split ";|$" | Select-Object -First 1 +$projectName = "$databaseName" +$projectPath = "." +# Backup as Baseline path - must be accessible by DB server - leave empty if not needed +$backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak + +# Set the schemas value +$Schemas = @("") # can be empty for SqlServer + +# Start Flyway Enterprise Trial and test connection +flyway auth -IAgreeToTheEula -startEnterpriseTrial +flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" +if ($LASTEXITCODE -ne 0) { + exit 1 +} + +# Initialize project - create folders and flyway.toml - delete existing project folder if exists +if (Test-Path -Path "$projectPath\$projectName") { + Remove-Item -Path $projectName -Recurse -Force +} +cd $projectPath +mkdir $projectName +cd ./$projectName +flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" + +if ($backupPath -ne "") { + # Add shadow environment to flyway.toml + $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' + $Url = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.shadow]`nurl = `"$Url`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" + ) +} + +<# # Modify flyway.toml to adjust comparison options +(Get-Content -Path "flyway.toml") ` +-replace 'ignorePermissions\s*=\s*false', 'ignorePermissions = true' ` +-replace 'ignoreUsersPermissionsAndRoleMemberships\s*=\s*false', 'ignoreUsersPermissionsAndRoleMemberships = true' ` +-replace 'includeDependencies\s*=\s*true', 'includeDependencies = false' | +Set-Content -Path "flyway.toml" + +# Define the file path +$filePath = "Filter.scpf" + +# Check if the file exists +if (Test-Path -Path $filePath) { + # Load the XML file + $xml = [xml](Get-Content -Path $filePath) + + # Find the element and update its child nodes + $noneElement = $xml.NamedFilter.Filter.Filters.None + $noneElement.Include = "False" + $noneElement.Expression = "((@SCHEMA LIKE 'cdc%'))" + + + $currentPath = Get-Location + $filePath = Join-Path -Path $currentPath -ChildPath $filePath + # Save the updated XML back to the file + $xml.Save($filePath) + Write-Host "Filter.scpf updated successfully." +} else { + Write-Host "Filter.scpf does not exist." +} +#> + +# Populate SchemaModel from dev database or from backup +if ($backupPath -eq "") { + flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$Url" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" + flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" +} else { + Write-Output "Restoring provided backup file to server URL and Populating SchemaModel from it" + flyway diff model "-diff.source=migrations" "-diff.target=schemaModel" "-diff.buildEnvironment=shadow" +} +cd .. \ No newline at end of file From 7cfa80b49a59e281ca88a6ab3ccc710b5ca37bce Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Tue, 9 Dec 2025 09:57:37 -0600 Subject: [PATCH 08/11] poc script integration --- .../fullFlywayPOCSetupAndRun.ps1 | 145 +++++++++++++++++- 1 file changed, 137 insertions(+), 8 deletions(-) diff --git a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 index e170bbd..c2b33f5 100644 --- a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 +++ b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 @@ -1,12 +1,12 @@ # Set parameters $databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql # connection string to prodlike database -$Url = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" +$baselineSourceIfNoBackup = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" $User = "" $Password = "" -$databaseName = ($Url -split "databaseName=")[1] -split ";|$" | Select-Object -First 1 +$databaseName = ($baselineSourceIfNoBackup -split "databaseName=")[1] -split ";|$" | Select-Object -First 1 $projectName = "$databaseName" -$projectPath = "." +$projectPath = "" # Backup as Baseline path - must be accessible by DB server - leave empty if not needed $backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak @@ -15,7 +15,7 @@ $Schemas = @("") # can be empty for SqlServer # Start Flyway Enterprise Trial and test connection flyway auth -IAgreeToTheEula -startEnterpriseTrial -flyway testConnection "-url=$Url" "-user=$User" "-password=$Password" "-schemas=$Schemas" +flyway testConnection "-url=$baselineSourceIfNoBackup" "-user=$User" "-password=$Password" "-schemas=$Schemas" if ($LASTEXITCODE -ne 0) { exit 1 } @@ -32,9 +32,9 @@ flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" if ($backupPath -ne "") { # Add shadow environment to flyway.toml $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' - $Url = $Url -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" + $shadowUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" (Add-Content -Path "flyway.toml" ` - -Value "`n`n[environments.shadow]`nurl = `"$Url`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" + -Value "`n`n[environments.shadow]`nurl = `"$shadowUrl`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" ) } @@ -71,10 +71,139 @@ if (Test-Path -Path $filePath) { # Populate SchemaModel from dev database or from backup if ($backupPath -eq "") { - flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$Url" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" + flyway diff model "-diff.source=dev" "-diff.target=schemaModel" "-environments.dev.url=$baselineSourceIfNoBackup" "-environments.dev.user=$User" "-environments.dev.password=$Password" "-environments.dev.schemas=$Schemas" flyway diff generate "-diff.source=schemaModel" "-diff.target=empty" "-generate.types=baseline" "-generate.description=Baseline" "-generate.version=1.0" } else { Write-Output "Restoring provided backup file to server URL and Populating SchemaModel from it" flyway diff model "-diff.source=migrations" "-diff.target=schemaModel" "-diff.buildEnvironment=shadow" } -cd .. \ No newline at end of file + +$pocSetupMessage = "`nYDo you want to set up a full POC environment with dev and test databases?" +if ($backupPath -ne "") { + $pocSetupMessage += " $backupPath WILL BE RESTORED multiple times to provided instance for dev and test databases. (Y/N)?" +} else { + $pocSetupMessage += "Provided database is assumed as test and new dev database WILL BE CREATED (Y/N)?" +} + +# Interactive prompt for full POC environment setup +$response = Read-Host $pocSetupMessage +if ($response -eq "Y" -or $response -eq "y") { + Write-Host "Setting up full POC environment..." + if ($backupPath -eq "") { + $devDatabaseName = $databaseName + '_dev' + $devUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"create-database`"" + ) + Write-Host "Creating dev database $devDatabaseName and running Baseline script to populate it..." + flyway migrate -environment=development + + } else { + $devDatabaseName = $databaseName + '_dev' + $devUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"backup`"`n`n[environments.development.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.development.resolvers.backup.sqlserver]`n generateWithMove = true" + ) + $testDatabaseName = $databaseName + '_test' + $testUrl = $Url -replace "databaseName=[^;]*", "databaseName=$testDatabaseName" + (Add-Content -Path "flyway.toml" ` + -Value "`n`n[environments.test]`nurl = `"$testUrl`"`nprovisioner = `"backup`"`n`n[environments.test.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.test.resolvers.backup.sqlserver]`n generateWithMove = true" + ) + Write-Host "Restoring backup file to create dev database $devDatabaseName" + flyway migrate -environment=development + Write-Host "Restoring backup file to create test database $testDatabaseName" + flyway migrate -environment=test + } + Write-Host "POC environment setup completed." + $skipped = $false + +} else { + Write-Host "Just showing flyway commands with documentation links to run manually" + $skipped = $true +} + +$sqlTablescript = " + CREATE TABLE AA_Test_Parent ( + ParentID INT PRIMARY KEY, + ParentName NVARCHAR(100) NOT NULL +); + +CREATE TABLE AA_Test_Child ( + ChildID INT PRIMARY KEY, + ChildName NVARCHAR(100) NOT NULL, + ParentID INT, + FOREIGN KEY (ParentID) REFERENCES AA_Test_Parent(ParentID) ON DELETE CASCADE +);" +# Interactive prompt for full POC environment setup +$runForMe = Read-Host "Use this script to create a sample migration - $sqlTablescript `n should I run this for you (Y)?`n Or do you want to run them yourself (N)?" +if ($runForMe -eq "Y" -or $runForMe -eq "y" -and -not $skipped) { + Write-Host "Creating sample tables in dev database..." + flyway migrate "-initSql=$sqlTablescript" "-url=$devUrl" "-user=$User" "-password=$Password" + Write-Host "Sample tables created in dev database." + $runScriptsForMe = $true +} else { + $response = Read-Host "Skipping sample table creation. Have you run them yourself against $devDatabaseName? (Y/N)?" +} +if ( $runForMe -eq "Y" -or $runForMe -eq "y" -or $response -eq "y" -or $response -eq "Y" -and -not $skipped) { + Write-Host "Creating migration scripts based on changes from dev to test database..." + flyway diff model "-diff.source=development" "-diff.target=schemaModel" + flyway diff generate "-diff.source=schemaModel" "-diff.target=migrations" "-generate.types=versioned,undo" "-diff.buildEnvironment=shadow" + Write-Host "Migration scripts created." +} else { + Write-Host "Skipping migration script creation." + +} + +Read-Host "Make some changes to the dev DB for Flyway to capture and generate a deployment script. Press enter once done." + +# # Variables to be changed by user +# $configFiles = "C:\WorkingFolders\FWD\NewWorldDB\flyway.toml,C:\WorkingFolders\FWD\NewWorldDB\flyway.user.toml" +# $workingDirectory = "C:\WorkingFolders\FWD\NewWorldDB" +# $schemaModelLocation = "./schema-model" +# $environment = "test" +# $target = "043.20250716213211" +# $cherryPick = "045.20251106201536" + +# # generic deployment +# Read-Host "Press Enter to run migrate command" +# flyway migrate -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment + +# # ================================================================================ + +# # create snapshot after changes +# Read-Host "Press Enter to run snapshot command" +# flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" + +# # ================================================================================ + +# # undo back to a specific target number +# Read-Host "Press Enter to run undo command" +# flyway undo -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment -target=$target + +# # ================================================================================ + +# # cherryPick forward +# Read-Host "Press Enter to run cherry-pick migrate command" +# flyway migrate -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment -cherryPick=$cherryPick + +# # ================================================================================ + +# # drift and code analysis report with snapshots + +# # run drift and code analysis (TO SEE DRIFT ALTER TARGET DB OUTSIDE OF FLYWAY) +# # check can be configured to fail on drift or code analysis triggering +# # it's possible to capture changes as well, but it is a duplication of what's stored in schema model and requires an extra database to deploy to in a CI fashion +# Read-Host "Press Enter to run drift check command" +# flyway check -drift -code -dryrun -environment=$environment -check.code.failOnError=false -check.failOnDrift=false -check.deployedSnapshot=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" + +# # ================================================================================ + +# # generic deployment +# Read-Host "Press Enter to run migrate command" +# flyway migrate -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment + +# # ================================================================================ + +# # create snapshot after changes +# Read-Host "Press Enter to run snapshot command" +# flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" \ No newline at end of file From 45ac7e343811b6680e68aa86d03127a8654ed983 Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Tue, 9 Dec 2025 10:02:19 -0600 Subject: [PATCH 09/11] fix scoping issue --- .../fullFlywayPOCSetupAndRun.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 index c2b33f5..c8b12df 100644 --- a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 +++ b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 @@ -13,6 +13,12 @@ $backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSS # Set the schemas value $Schemas = @("") # can be empty for SqlServer +# Initialize variables at script level - these will be provided later do not fill +$devDatabaseName = "" +$devUrl = "" +$testDatabaseName = "" +$testUrl = "" + # Start Flyway Enterprise Trial and test connection flyway auth -IAgreeToTheEula -startEnterpriseTrial flyway testConnection "-url=$baselineSourceIfNoBackup" "-user=$User" "-password=$Password" "-schemas=$Schemas" @@ -206,4 +212,6 @@ Read-Host "Make some changes to the dev DB for Flyway to capture and generate a # # create snapshot after changes # Read-Host "Press Enter to run snapshot command" -# flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" \ No newline at end of file +# flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" + +cd .. \ No newline at end of file From c9151bfa0e7e939604e601e1090413ce52cc7b94 Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Tue, 9 Dec 2025 10:33:08 -0600 Subject: [PATCH 10/11] iterate --- .../fullFlywayPOCSetupAndRun.ps1 | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 index c8b12df..3c9113e 100644 --- a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 +++ b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 @@ -1,12 +1,16 @@ # Set parameters $databaseType = "SqlServer" # alt values: SqlServer Oracle PostgreSql MySql # connection string to prodlike database -$baselineSourceIfNoBackup = "jdbc:sqlserver://localhost;databaseName=NewWorldDB_Dev;encrypt=false;integratedSecurity=true;trustServerCertificate=true" +# This POC will create a dev, test, shadow DB - this name will be in the root of all subsequent names +$baseDBName = "flywayPOC" +$devDBName = $baseDBName + "_dev" +$baselineSourceIfNoBackup = "jdbc:sqlserver://localhost;databaseName=" + $baseDBName + ";encrypt=false;integratedSecurity=true;trustServerCertificate=true" +$devDBConnectionString = "jdbc:sqlserver://localhost;databaseName=" + $devDBName + ";encrypt=false;integratedSecurity=true;trustServerCertificate=true" $User = "" $Password = "" -$databaseName = ($baselineSourceIfNoBackup -split "databaseName=")[1] -split ";|$" | Select-Object -First 1 -$projectName = "$databaseName" -$projectPath = "" +# Can be changed to a different name than DB name +$projectName = "$baseDBName" +$projectPath = "." # Backup as Baseline path - must be accessible by DB server - leave empty if not needed $backupPath = "C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak" # eg C:\\Program Files\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\MSSQL\\Backup\\Northwind.bak @@ -19,13 +23,6 @@ $devUrl = "" $testDatabaseName = "" $testUrl = "" -# Start Flyway Enterprise Trial and test connection -flyway auth -IAgreeToTheEula -startEnterpriseTrial -flyway testConnection "-url=$baselineSourceIfNoBackup" "-user=$User" "-password=$Password" "-schemas=$Schemas" -if ($LASTEXITCODE -ne 0) { - exit 1 -} - # Initialize project - create folders and flyway.toml - delete existing project folder if exists if (Test-Path -Path "$projectPath\$projectName") { Remove-Item -Path $projectName -Recurse -Force @@ -37,7 +34,7 @@ flyway init "-init.projectName=$projectName" "-init.databaseType=$databaseType" if ($backupPath -ne "") { # Add shadow environment to flyway.toml - $ShadowDatabaseName = $databaseName + '_${env.UserName}_shadow' + $ShadowDatabaseName = $baseDBName + '_${env.UserName}_shadow' $shadowUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$ShadowDatabaseName" (Add-Content -Path "flyway.toml" ` -Value "`n`n[environments.shadow]`nurl = `"$shadowUrl`"`nprovisioner = `"backup`"`n`n[environments.shadow.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.shadow.resolvers.backup.sqlserver]`n generateWithMove = true" @@ -96,7 +93,7 @@ $response = Read-Host $pocSetupMessage if ($response -eq "Y" -or $response -eq "y") { Write-Host "Setting up full POC environment..." if ($backupPath -eq "") { - $devDatabaseName = $databaseName + '_dev' + $devDatabaseName = $devDBName $devUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" (Add-Content -Path "flyway.toml" ` -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"create-database`"" @@ -105,12 +102,12 @@ if ($response -eq "Y" -or $response -eq "y") { flyway migrate -environment=development } else { - $devDatabaseName = $databaseName + '_dev' + $devDatabaseName = $devDBName $devUrl = $baselineSourceIfNoBackup -replace "databaseName=[^;]*", "databaseName=$devDatabaseName" (Add-Content -Path "flyway.toml" ` -Value "`n`n[environments.development]`nurl = `"$devUrl`"`nprovisioner = `"backup`"`n`n[environments.development.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.development.resolvers.backup.sqlserver]`n generateWithMove = true" ) - $testDatabaseName = $databaseName + '_test' + $testDatabaseName = $baseDBName + '_test' $testUrl = $Url -replace "databaseName=[^;]*", "databaseName=$testDatabaseName" (Add-Content -Path "flyway.toml" ` -Value "`n`n[environments.test]`nurl = `"$testUrl`"`nprovisioner = `"backup`"`n`n[environments.test.resolvers.backup]`nbackupFilePath = `"$backupPath`"`nbackupVersion = `"000`"`n`n [environments.test.resolvers.backup.sqlserver]`n generateWithMove = true" @@ -128,6 +125,13 @@ if ($response -eq "Y" -or $response -eq "y") { $skipped = $true } +# Start Flyway Enterprise Trial and test connection +flyway auth -IAgreeToTheEula -startEnterpriseTrial +flyway testConnection "-url=$devDBConnectionString" "-user=$User" "-password=$Password" "-schemas=$Schemas" +if ($LASTEXITCODE -ne 0) { + exit 1 +} + $sqlTablescript = " CREATE TABLE AA_Test_Parent ( ParentID INT PRIMARY KEY, From 5ffaba6bb76e9e342d881f508e35893a5c1b7e34 Mon Sep 17 00:00:00 2001 From: Andrew Guard Date: Tue, 9 Dec 2025 11:13:01 -0600 Subject: [PATCH 11/11] in flight --- .../fullFlywayPOCSetupAndRun.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 index 3c9113e..0a48cc9 100644 --- a/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 +++ b/Generic-POC-Flyway-Commands/fullFlywayPOCSetupAndRun.ps1 @@ -126,9 +126,13 @@ if ($response -eq "Y" -or $response -eq "y") { } # Start Flyway Enterprise Trial and test connection -flyway auth -IAgreeToTheEula -startEnterpriseTrial -flyway testConnection "-url=$devDBConnectionString" "-user=$User" "-password=$Password" "-schemas=$Schemas" -if ($LASTEXITCODE -ne 0) { +flyway auth -IAgreeToTheEula -startEnterpriseTrial 2>&1 | Out-Null +flyway testConnection "-url=$devDBConnectionString" "-user=$User" "-password=$Password" "-schemas=$Schemas" 2>&1 | ForEach-Object { + if ($_ -notmatch "400") { + $_ + } +} +if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 400) { exit 1 }