mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
fix(deploy): safe-db-push uses pnpm dlx when local drizzle-kit is missing
The Mac Mini runner doesn't run \`pnpm install\` (every service builds inside Docker), so per-service node_modules/.bin/drizzle-kit isn't present. The first deploy with the new migration step printed \`ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "drizzle-kit" not found\` and silently treated every service as "no schema changes — clean". Pick the invocation mode at runtime: \`pnpm exec drizzle-kit\` if a local binary exists, otherwise \`pnpm dlx drizzle-kit\`. dlx caches the package in the global pnpm store after the first fetch, so subsequent calls are fast. drizzle-kit reads its config from cwd, so it still picks up each service's drizzle.config.ts correctly. Smoke-tested locally against services/mana-auth — script reports "no schema changes — clean" instead of failing silently. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b1fa55dbca
commit
e4d9dc5b2e
1 changed files with 14 additions and 2 deletions
|
|
@ -57,13 +57,25 @@ fi
|
|||
|
||||
cd "$SVC_DIR"
|
||||
|
||||
# Pick how we'll invoke drizzle-kit. The Mac Mini runner doesn't run
|
||||
# `pnpm install` for the workspace (everything builds inside Docker),
|
||||
# so the per-service node_modules/.bin/drizzle-kit binary is missing.
|
||||
# `pnpm dlx` fetches drizzle-kit on demand, caches it in the global
|
||||
# pnpm store, and is then fast on every subsequent call. drizzle-kit
|
||||
# reads its config from cwd so it still finds drizzle.config.ts here.
|
||||
if pnpm exec --silent drizzle-kit --version >/dev/null 2>&1; then
|
||||
DRIZZLE="pnpm exec drizzle-kit"
|
||||
else
|
||||
DRIZZLE="pnpm dlx drizzle-kit"
|
||||
fi
|
||||
|
||||
# Snapshot the existing migration set before we generate. Anything new
|
||||
# afterwards is the diff this push would apply.
|
||||
PRE_GEN_FILES=$(find drizzle -maxdepth 2 -name '*.sql' 2>/dev/null | sort || true)
|
||||
|
||||
# Generate-only — does not touch the database.
|
||||
echo "[safe-db-push] $SVC: generating diff…"
|
||||
GEN_OUT=$(pnpm exec drizzle-kit generate --name "__ci_safety_check_$$" 2>&1 || true)
|
||||
GEN_OUT=$($DRIZZLE generate --name "__ci_safety_check_$$" 2>&1 || true)
|
||||
echo "$GEN_OUT" | tail -20
|
||||
|
||||
POST_GEN_FILES=$(find drizzle -maxdepth 2 -name '*.sql' 2>/dev/null | sort || true)
|
||||
|
|
@ -120,5 +132,5 @@ fi
|
|||
|
||||
# Additive only — safe to apply.
|
||||
echo "[safe-db-push] $SVC: ✓ additive only, applying…"
|
||||
pnpm exec drizzle-kit push --force
|
||||
$DRIZZLE push --force
|
||||
echo "[safe-db-push] $SVC: ✓ schema is now in sync"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue