Guest User

Untitled

a guest
Oct 26th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. ###Determine deployment environment for credential extraction
  2. echo "Determining the deployment environment"
  3. case "${bamboo_deploy_environment}" in
  4. prod)
  5. path=prod
  6. dbs=( db1 db2 db3 )
  7. ;;
  8. stage)
  9. path=stage
  10. dbs=( db1 db2 db3 )
  11. ;;
  12. *)
  13. path=dev
  14. dbs=( db1 db2 db3 )
  15. ;;
  16. esac
  17. echo "Environment for credentials unlock is ${path}"
  18.  
  19. packages=( .sql .trg .pks .pkb .fnc .typ .java .class .properties .config .txt .dat )
  20. echo "Packages to loop through when deploying flyway are ${packages[*]}"
  21.  
  22. echo "Databases to run against in this environment are ${dbs[*]}"
  23. ###Flyway execution stuff
  24. for db in "${dbs[@]}"
  25. do
  26. if [ -z ${db} ]; then
  27. echo "No db specified"
  28. exit 2
  29. else
  30. echo "Working on db ${db}"
  31. case "${db}" in
  32. db1)
  33. sid=db1
  34. host=db1.fqdn
  35. port=$portnm
  36. ;;
  37. db2)
  38. sid=db2
  39. host=db2.fqdn
  40. port=$portnm
  41. ;;
  42. db3)
  43. sid=db3
  44. host=db3.fqdn
  45. port=$portnm
  46. ;;
  47. esac
  48. fi
  49.  
  50. echo "Current directory is `pwd`" && echo "n Contents of current directory as `ls -l`"
  51.  
  52. echo "Executing Flyway against ${db} for package ${pkg}"
  53. for pkg in "${packages[@]}"
  54. ###Target the specific migrations starting folder (it goes recursively)
  55. do
  56. case "${pkg}" in
  57. .sql)
  58. loc=filesystem:${db}/migrations
  59. ;;
  60. *)
  61. loc=filesystem:${db}
  62. migrateParams="-repeatableSqlMigrationPrefix=RM -table=REPEATABLE_MIGRATIONS_HISTORY"
  63. ;;
  64. esac
  65. echo "Running flyway for package type ${pkg} against ${db} db with location set to ${loc}"
  66.  
  67. baseParams="-configFile=${db}/migrations/base.conf -locations=${loc} -url=jdbc:oracle:thin:@${host}:${port}:${sid}"
  68. migrateParams="${migrateParams} -sqlMigrationSuffix=${pkg} ${baseParams}"
  69. addParams=" -ignoreMissingMigrations=True"
  70. flyway "repair" "${migrateParams}"
  71. flyway "migrate" "${migrateParams}${addParams}"
  72. echo "Finished with ${pkg} against ${db} db"
  73. unset baseParams
  74. unset migrateParams
  75. unset addParams
  76. done
  77. done
  78.  
  79. echo "Finished with the migration runs"
  80.  
  81. select "description", "script", "checksum", count(1)
  82. from FLYWAY.repeatable_migrations_history
  83. group by "description", "script", "checksum"
  84. order by count(1) desc, "script";
Add Comment
Please, Sign In to add comment