Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###Determine deployment environment for credential extraction
- echo "Determining the deployment environment"
- case "${bamboo_deploy_environment}" in
- prod)
- path=prod
- dbs=( db1 db2 db3 )
- ;;
- stage)
- path=stage
- dbs=( db1 db2 db3 )
- ;;
- *)
- path=dev
- dbs=( db1 db2 db3 )
- ;;
- esac
- echo "Environment for credentials unlock is ${path}"
- packages=( .sql .trg .pks .pkb .fnc .typ .java .class .properties .config .txt .dat )
- echo "Packages to loop through when deploying flyway are ${packages[*]}"
- echo "Databases to run against in this environment are ${dbs[*]}"
- ###Flyway execution stuff
- for db in "${dbs[@]}"
- do
- if [ -z ${db} ]; then
- echo "No db specified"
- exit 2
- else
- echo "Working on db ${db}"
- case "${db}" in
- db1)
- sid=db1
- host=db1.fqdn
- port=$portnm
- ;;
- db2)
- sid=db2
- host=db2.fqdn
- port=$portnm
- ;;
- db3)
- sid=db3
- host=db3.fqdn
- port=$portnm
- ;;
- esac
- fi
- echo "Current directory is `pwd`" && echo "n Contents of current directory as `ls -l`"
- echo "Executing Flyway against ${db} for package ${pkg}"
- for pkg in "${packages[@]}"
- ###Target the specific migrations starting folder (it goes recursively)
- do
- case "${pkg}" in
- .sql)
- loc=filesystem:${db}/migrations
- ;;
- *)
- loc=filesystem:${db}
- migrateParams="-repeatableSqlMigrationPrefix=RM -table=REPEATABLE_MIGRATIONS_HISTORY"
- ;;
- esac
- echo "Running flyway for package type ${pkg} against ${db} db with location set to ${loc}"
- baseParams="-configFile=${db}/migrations/base.conf -locations=${loc} -url=jdbc:oracle:thin:@${host}:${port}:${sid}"
- migrateParams="${migrateParams} -sqlMigrationSuffix=${pkg} ${baseParams}"
- addParams=" -ignoreMissingMigrations=True"
- flyway "repair" "${migrateParams}"
- flyway "migrate" "${migrateParams}${addParams}"
- echo "Finished with ${pkg} against ${db} db"
- unset baseParams
- unset migrateParams
- unset addParams
- done
- done
- echo "Finished with the migration runs"
- select "description", "script", "checksum", count(1)
- from FLYWAY.repeatable_migrations_history
- group by "description", "script", "checksum"
- order by count(1) desc, "script";
Add Comment
Please, Sign In to add comment