Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions POC/Powershell/cookbook.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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
flyway migrate -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment

# create snapshot after changes
flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation"

# undo back to a specific target number
flyway undo -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment -target=$target

# cherryPick forward
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
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
flyway migrate -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation" -schemaModelSchemas= -environment=$environment

# create snapshot after changes
flyway snapshot -environment=$environment -filename=snapshothistory:current -configFiles="$configFiles" -workingDirectory="$workingDirectory" -schemaModelLocation="$schemaModelLocation"
34 changes: 34 additions & 0 deletions POC/Unix/cookbook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Variables to be changed by user
CONFIG_FILES="/path/to/flyway.toml,/path/to/flyway.user.toml"
WORKING_DIRECTORY="/path/to/working/directory"
SCHEMA_MODEL_LOCATION="./schema-model"
ENVIRONMENT="test"
TARGET="043.20250716213211"
CHERRY_PICK="045.20251106201536"

# generic deployment
flyway migrate -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION" -schemaModelSchemas= -environment=$ENVIRONMENT

# create snapshot after changes
flyway snapshot -environment=$ENVIRONMENT -filename=snapshothistory:current -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION"

# undo back to a specific target number
flyway undo -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION" -schemaModelSchemas= -environment=$ENVIRONMENT -target=$TARGET

# cherryPick forward
flyway migrate -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION" -schemaModelSchemas= -environment=$ENVIRONMENT -cherryPick=$CHERRY_PICK

# 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
flyway check -drift -code -dryrun -environment=$ENVIRONMENT -check.code.failOnError=false -check.failOnDrift=false -check.deployedSnapshot=snapshothistory:current -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION"

# generic deployment
flyway migrate -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION" -schemaModelSchemas= -environment=$ENVIRONMENT

# create snapshot after changes
flyway snapshot -environment=$ENVIRONMENT -filename=snapshothistory:current -configFiles="$CONFIG_FILES" -workingDirectory="$WORKING_DIRECTORY" -schemaModelLocation="$SCHEMA_MODEL_LOCATION"