ci: attempt to fix Deployment
This commit is contained in:
@@ -2,22 +2,31 @@
|
||||
set -e
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Resolve any previously failed migrations so deploy can proceed.
|
||||
# Only migrations explicitly marked as "Failed" in the status output are
|
||||
# resolved. We grep for lines containing "Failed" and extract the name.
|
||||
# 1. Print current migration status for debugging.
|
||||
# ---------------------------------------------------------------------------
|
||||
echo "[migrate] Checking for failed migrations..."
|
||||
echo "[migrate] Checking database migration status..."
|
||||
STATUS_OUTPUT=$(bunx prisma migrate status 2>&1 || true)
|
||||
echo "$STATUS_OUTPUT"
|
||||
|
||||
# Only resolve migrations whose status line explicitly says "Failed"
|
||||
echo "$STATUS_OUTPUT" | grep -i "failed" | grep -oE '[0-9]{14}_[a-zA-Z_]+' | while read -r MIGRATION; do
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Resolve any "Failed" migrations as rolled-back so deploy can re-apply.
|
||||
# All migration SQL in this repo is written to be idempotent (using
|
||||
# IF NOT EXISTS / DO $$ ... $$ guards), so a re-run after resolving will
|
||||
# succeed even when schema drift has occurred from a prior db push.
|
||||
#
|
||||
# Regex matches both named (20260307010000_add_foo) and unnamed (20260125205653)
|
||||
# migration timestamps so the initial baseline migration is also covered.
|
||||
# ---------------------------------------------------------------------------
|
||||
FAILED=$(printf '%s\n' "$STATUS_OUTPUT" | grep -i "failed" | grep -oE '[0-9]{14}(_[a-zA-Z_]+)?' || true)
|
||||
|
||||
for MIGRATION in $FAILED; do
|
||||
echo "[migrate] Resolving failed migration: $MIGRATION"
|
||||
bunx prisma migrate resolve --rolled-back "$MIGRATION" || true
|
||||
bunx prisma migrate resolve --rolled-back "$MIGRATION"
|
||||
done
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Deploy all pending migrations from the migrations directory.
|
||||
# 3. Deploy all pending migrations from the migrations directory.
|
||||
# ---------------------------------------------------------------------------
|
||||
echo "[migrate] Running prisma migrate deploy..."
|
||||
bunx prisma migrate deploy
|
||||
echo "[migrate] All migrations applied successfully."
|
||||
|
||||
Reference in New Issue
Block a user