From e4d9dc5b2ebf046017c84f3095c564d15fdd5463 Mon Sep 17 00:00:00 2001 From: Till JS Date: Tue, 28 Apr 2026 16:57:35 +0200 Subject: [PATCH] fix(deploy): safe-db-push uses pnpm dlx when local drizzle-kit is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- scripts/mac-mini/safe-db-push.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/mac-mini/safe-db-push.sh b/scripts/mac-mini/safe-db-push.sh index f143623e1..44dbb8181 100755 --- a/scripts/mac-mini/safe-db-push.sh +++ b/scripts/mac-mini/safe-db-push.sh @@ -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"