push
This commit is contained in:
@@ -7,6 +7,8 @@ services:
|
|||||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me}
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-toir}
|
POSTGRES_DB: ${POSTGRES_DB:-toir}
|
||||||
|
# UTF-8 cluster (applies only on first volume init) — migrations use Cyrillic enum labels
|
||||||
|
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --locale=C.UTF-8"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
@@ -64,7 +66,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
server:
|
server:
|
||||||
condition: service_healthy
|
# Do not wait for healthy: if migrations fail, stack stays up so you can read server logs.
|
||||||
|
condition: service_started
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/healthz >/dev/null 2>&1 || exit 1"]
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/healthz >/dev/null 2>&1 || exit 1"]
|
||||||
interval: 15s
|
interval: 15s
|
||||||
|
|||||||
@@ -2,20 +2,35 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
PRISMA_BIN="./node_modules/.bin/prisma"
|
PRISMA_BIN="./node_modules/.bin/prisma"
|
||||||
|
SCHEMA="prisma/schema.prisma"
|
||||||
|
|
||||||
if [ ! -f "$PRISMA_BIN" ]; then
|
if [ ! -f "$PRISMA_BIN" ]; then
|
||||||
echo "Prisma CLI not found at $PRISMA_BIN"
|
echo "Prisma CLI not found at $PRISMA_BIN"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Applying database migrations..."
|
export PRISMA_HIDE_UPDATE_MESSAGE=1
|
||||||
|
|
||||||
|
run_migrate() {
|
||||||
|
"$PRISMA_BIN" migrate deploy --schema "$SCHEMA" --skip-generate
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Applying database migrations (schema=$SCHEMA)..."
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt 15 ]; do
|
while [ "$i" -lt 15 ]; do
|
||||||
if "$PRISMA_BIN" migrate deploy; then
|
if run_migrate; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
if [ "$i" -eq 15 ]; then
|
if [ "$i" -eq 15 ]; then
|
||||||
echo "prisma migrate deploy failed after 15 attempts"
|
echo "----------------------------------------------------------------"
|
||||||
|
echo "prisma migrate deploy failed after 15 attempts."
|
||||||
|
echo "Check: docker logs toir-server"
|
||||||
|
echo "If the DB volume has a broken migration history, remove volume"
|
||||||
|
echo "kis-toir_postgres-data once (all DB data lost) or fix _prisma_migrations."
|
||||||
|
echo "--- prisma migrate status ---"
|
||||||
|
"$PRISMA_BIN" migrate status --schema "$SCHEMA" || true
|
||||||
|
echo "----------------------------------------------------------------"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Migrate failed or DB not ready; retrying in 2s ($i/15)..."
|
echo "Migrate failed or DB not ready; retrying in 2s ($i/15)..."
|
||||||
|
|||||||
Reference in New Issue
Block a user