Skip to content

Commit 2626482

Browse files
ci(migrations): fail dev schema push with an actionable error on rename/drop prompt
`drizzle-kit push --force` only suppresses the data-loss confirm, not the rename-vs-drop disambiguation prompt. That prompt fires whenever a diff both adds and drops tables/columns at once (e.g. migration 0231 created sim_trigger_state while dropping the workspace_notification_* tables), and in CI it crashes with a bare "Interactive prompts require a TTY" stack trace. Catch that specific failure in the dev push step and emit a GitHub error annotation explaining the cause and the fix (drop the stale objects on the dev DB to match schema.ts — the same DROPs the versioned migration already applied to staging/prod), instead of leaving an opaque trace. Exit status is preserved either way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e2523e0 commit 2626482

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/migrations.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,18 @@ jobs:
6969
7070
if [ "${ENVIRONMENT}" = "dev" ]; then
7171
echo "Dev environment — pushing schema directly (db:push)"
72-
bun run db:push --force
72+
# `--force` only suppresses the data-loss confirm, not drizzle's
73+
# rename-vs-drop prompt, which fires (and crashes, no TTY) when a
74+
# diff both adds and drops tables/columns at once. Turn that opaque
75+
# crash into an actionable failure instead of a bare stack trace.
76+
push_output="$(bun run db:push --force 2>&1)" && push_status=0 || push_status=$?
77+
echo "$push_output"
78+
if [ "$push_status" -ne 0 ]; then
79+
if printf '%s' "$push_output" | grep -q 'Interactive prompts require a TTY'; then
80+
echo "::error title=Dev schema push needs manual reconciliation::drizzle-kit push hit an interactive rename/drop prompt that CI cannot answer. The dev DB has drifted from schema.ts: it still holds table(s)/column(s) the schema no longer declares while the schema also adds new ones, so drizzle cannot tell a rename from a drop+create. Fix: drop the stale objects on the dev DB to match schema.ts — the same DROPs the latest versioned migration already applied to staging/prod (grep packages/db/migrations for the most recent DROP TABLE / DROP COLUMN) — then re-run this workflow. --force cannot bypass this prompt."
81+
fi
82+
exit "$push_status"
83+
fi
7384
else
7485
echo "Applying versioned migrations (db:migrate)"
7586
bun run ./scripts/migrate.ts

0 commit comments

Comments
 (0)