Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DETS migration script #2522

Merged
merged 1 commit into from
Feb 4, 2025
Merged
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
40 changes: 40 additions & 0 deletions bin/migrate-dets.sh
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