mirror of
https://github.com/MatthewL246/pretendo-docker.git
synced 2026-10-02 14:58:00 -05:00
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.
This commit is contained in:
18
scripts/internal/firstrun-postgres-container.sh
Executable file
18
scripts/internal/firstrun-postgres-container.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# shellcheck source=./framework.sh
|
||||
source "$(dirname "$(realpath "$0")")/framework.sh"
|
||||
parse_arguments "$@"
|
||||
|
||||
print_info "Setting up the Postgres container..."
|
||||
|
||||
load_dotenv postgres.env postgres.local.env
|
||||
postgres_init_script=$(cat "$git_base_dir/scripts/run-in-container/postgres-init.sh")
|
||||
|
||||
compose_no_progress up -d postgres
|
||||
run_command_until_success "Waiting for Postgres to be ready..." 5 \
|
||||
docker compose exec postgres psql -U "$POSTGRES_USER" -c "\\l"
|
||||
|
||||
run_verbose docker compose exec postgres sh -c "$postgres_init_script"
|
||||
|
||||
print_success "Postgres container is set up."
|
||||
@@ -9,7 +9,7 @@ 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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user