|
@@ -18,7 +18,13 @@ done
|
|
|
echo "PostgreSQL is ready!"
|
|
echo "PostgreSQL is ready!"
|
|
|
|
|
|
|
|
echo "Applying database migrations..."
|
|
echo "Applying database migrations..."
|
|
|
-if ! npx prisma migrate deploy 2>/dev/null; then
|
|
|
|
|
|
|
+# Keep stderr rather than discarding it: when the retry below also fails, the
|
|
|
|
|
+# first error is the one that says why, and swallowing it left the container
|
|
|
|
|
+# dying with no reason recorded.
|
|
|
|
|
+migrate_err=$(mktemp)
|
|
|
|
|
+if ! npx prisma migrate deploy 2>"$migrate_err"; then
|
|
|
|
|
+ echo "First migrate attempt failed:"
|
|
|
|
|
+ sed 's/^/ /' "$migrate_err" >&2
|
|
|
# P3005: existing DB without migration history (from db push).
|
|
# P3005: existing DB without migration history (from db push).
|
|
|
# Create empty migration table so migrate deploy can run.
|
|
# Create empty migration table so migrate deploy can run.
|
|
|
# 0_init is fully idempotent — safe on any DB state.
|
|
# 0_init is fully idempotent — safe on any DB state.
|
|
@@ -26,6 +32,7 @@ if ! npx prisma migrate deploy 2>/dev/null; then
|
|
|
npx prisma db execute --stdin <<< 'CREATE TABLE IF NOT EXISTS "_prisma_migrations" ("id" VARCHAR(36) PRIMARY KEY NOT NULL, "checksum" VARCHAR(64) NOT NULL, "finished_at" TIMESTAMPTZ, "migration_name" VARCHAR(255) NOT NULL, "logs" TEXT, "rolled_back_at" TIMESTAMPTZ, "started_at" TIMESTAMPTZ NOT NULL DEFAULT now(), "applied_steps_count" INTEGER NOT NULL DEFAULT 0)'
|
|
npx prisma db execute --stdin <<< 'CREATE TABLE IF NOT EXISTS "_prisma_migrations" ("id" VARCHAR(36) PRIMARY KEY NOT NULL, "checksum" VARCHAR(64) NOT NULL, "finished_at" TIMESTAMPTZ, "migration_name" VARCHAR(255) NOT NULL, "logs" TEXT, "rolled_back_at" TIMESTAMPTZ, "started_at" TIMESTAMPTZ NOT NULL DEFAULT now(), "applied_steps_count" INTEGER NOT NULL DEFAULT 0)'
|
|
|
npx prisma migrate deploy
|
|
npx prisma migrate deploy
|
|
|
fi
|
|
fi
|
|
|
|
|
+rm -f "$migrate_err"
|
|
|
echo "Migrations applied successfully!"
|
|
echo "Migrations applied successfully!"
|
|
|
|
|
|
|
|
# Photo embedding is the one thing here that depends on a native module, and
|
|
# Photo embedding is the one thing here that depends on a native module, and
|