-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.sh
42 lines (30 loc) · 1.06 KB
/
cmd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
MISSING_VARS=()
[ -z "$DB_URL" ] && MISSING_VARS+=("DB_URL")
[ -z "$DB_USER" ] && MISSING_VARS+=("DB_USER")
[ -z "$DB_PASSWORD" ] && MISSING_VARS+=("DB_PASSWORD")
if [ ${#MISSING_VARS[@]} -gt 0 ]; then
echo "Error: The following required environment variable(s) are not set: ${MISSING_VARS[*]}"
exit 1
fi
MIGRATION_PATH=${MIGRATION_PATH:-/sql}
SEED_PATH=${SEED_PATH:-/seed}
USE_SEED=${USE_SEED:-false}
if [ "$USE_SEED" = "true" ]; then
LOCATIONS="filesystem:$MIGRATION_PATH,filesystem:$SEED_PATH"
else
LOCATIONS="filesystem:$MIGRATION_PATH"
fi
echo "Invoking migrations from path $LOCATIONS"
if [ -z ${DB_CONNECTION_CHECK+x} ];
then
echo "DB_CONNECTION_CHECK is not set. Skipping connection test";
else
until flyway-10.20.0/flyway validate -url=$DB_URL -user=$DB_USER -password=$DB_PASSWORD;
do
echo "DB is unavailable - sleeping";
sleep 1
done
echo "DB is up and running";
fi
flyway-10.20.0/flyway ${FLYWAY_CMD:-migrate} -url=$DB_URL -user=$DB_USER -password=$DB_PASSWORD -locations=$LOCATIONS