generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d441107
commit ff12e2e
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is a wrapper around various flyway gradle tasks, and can be used to perform data migration against a named database in DETS. | ||
# The script requires the environment variables FLYWAY_USER and FLYWAY_PASSWORD to be set, and the executed tasks take their configuration from the flyway{} | ||
# block in the build.gradle file located in the project root. | ||
|
||
set -euo pipefail | ||
|
||
if [ -z "${FLYWAY_USER:-}" ]; then | ||
echo "Env var FLYWAY_USER must be set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${FLYWAY_PASSWORD:-}" ]; then | ||
echo "Env var FLYWAY_PASSWORD must be set" | ||
exit 1 | ||
fi | ||
|
||
DATABASE_NAME=${1:-} | ||
if [ -z "$DATABASE_NAME" ]; then | ||
echo "Usage: $0 <database_name>" | ||
exit 1 | ||
fi | ||
|
||
# Port 5433 is the local port that is mapped to the DB on the production bastion, per | ||
# https://tools.hmcts.net/confluence/display/DMP/Applying+Flyway+changes+to+Migration | ||
export FLYWAY_URL="jdbc:postgresql://localhost:5433/$DATABASE_NAME" | ||
|
||
cd .. | ||
./gradlew flywayInfo | ||
|
||
read -p 'Execute flywayMigrate? (y/n): ' continue | ||
if [ "$continue" != "y" ] | ||
then | ||
exit 1 | ||
fi | ||
|
||
./gradlew flywayMigrate | ||
./gradlew flywayValidate | ||
./gradlew flywayInfo |