feat(migration) add migration

This commit is contained in:
lumither committed 2025-10-13 14:36:21 -04:00
1 parent 02e7166fcb
commit 3a4af1ae8d
9 files changed
+84 -22

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -e
PGPASSFILE="/root/.pgpass"
echo "postgres:5432:${POSTGRES_DB}:${POSTGRES_USER}:${POSTGRES_PASSWORD}" > "$PGPASSFILE"
chmod 600 "$PGPASSFILE"
echo "waiting for postgres"
until pg_isready -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB"; do
echo "retrying, sleep 2s"
sleep 2
done
echo "db ready, running migrations"
for file in /migrations/*.sql; do
echo "applying $file"
psql -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f "$file"
done
echo "migration complete"