pretendo-docker/scripts/internal/migrations.sh
Matthew Lopez 6290a7f269
Switch to running the Postgres init script manually during setup
This should hopefully fix the issue where some people run the setup script but no Postgres databases get created.
2024-07-13 19:54:25 -04:00

20 lines
779 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 -At -U "$POSTGRES_USER" -d friends -c "SELECT 1 FROM information_schema.schemata WHERE schema_name = '3ds';") = "1" ]]; 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."