-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflyway.sh
More file actions
48 lines (38 loc) · 1.19 KB
/
flyway.sh
File metadata and controls
48 lines (38 loc) · 1.19 KB
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
43
44
45
46
47
48
#!/bin/bash
# makes script exit on errors (-e) and on references to unset variables (-u)
set -eu
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPOSE_FILE="$DIR/../flyway/compose.yaml"
source "$DIR/.env"
echo -e "\n"
# Check if a parameter is provided
if [ $# -eq 0 ]; then
echo "Error: No parameter provided"
echo "Usage: $0 <command>"
echo "Available commands: clean, migrate, info, validate, repair, version"
echo -e "\n"
exit 1
fi
# Get the command parameter
command="$1"
# Define valid commands
valid_commands=("clean" "migrate" "info" "validate" "repair" "version")
# Check if the command is valid
is_valid=0
for valid_command in "${valid_commands[@]}"; do
if [ "$command" = "$valid_command" ]; then
is_valid=1
break
fi
done
# If command is not valid, show error and usage
if [ $is_valid -eq 0 ]; then
echo "Error: Invalid command '$command'"
echo "Usage: $0 <command>"
echo "Available commands: clean, migrate, info, validate, repair, version"
echo -e "\n"
exit 1
fi
# Execute the appropriate docker compose command
docker compose --file "$COMPOSE_FILE" --env-file "$DIR/.env" run --rm flyway -c "flyway ${command}"
echo -e "\n"