pretendo-docker/scripts/internal/migrations.sh
2024-06-27 10:42:23 -04:00

20 lines
793 B
Bash
Executable File

#!/usr/bin/env bash
# shellcheck source=./framework.sh
source "$(dirname "$(realpath "$0")")/framework.sh"
parse_arguments "$@"
print_info "Running migrations..."
load_dotenv postgres.env postgres.local.env
compose_no_progress up -d postgres
if [[ $(docker compose exec postgres psql -U "$POSTGRES_USER" -d friends -c "SELECT schema_name FROM information_schema.schemata WHERE schema_name = '3ds';") == *"(1 row)" ]]; then
print_info "Migrating friends to the nex-go rewrite..."
migration=$(cat "$git_base_dir/scripts/run-in-container/friends-nex-go-rewrite-migration.sql")
# shellcheck disable=SC2046
docker compose exec postgres psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d friends -c "$migration" $(if_not_verbose --quiet)
fi
print_success "Migrations are complete."