-
Notifications
You must be signed in to change notification settings - Fork 3.7k
ci(migrations): fail dev schema push with an actionable error on rename/drop prompt #4999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,18 @@ jobs: | |
|
|
||
| if [ "${ENVIRONMENT}" = "dev" ]; then | ||
| echo "Dev environment — pushing schema directly (db:push)" | ||
| bun run db:push --force | ||
| # `--force` only suppresses the data-loss confirm, not drizzle's | ||
| # rename-vs-drop prompt, which fires (and crashes, no TTY) when a | ||
| # diff both adds and drops tables/columns at once. Turn that opaque | ||
| # crash into an actionable failure instead of a bare stack trace. | ||
| push_output="$(bun run db:push --force 2>&1)" && push_status=0 || push_status=$? | ||
| echo "$push_output" | ||
|
Comment on lines
+76
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| if [ "$push_status" -ne 0 ]; then | ||
| if printf '%s' "$push_output" | grep -q 'Interactive prompts require a TTY'; then | ||
| 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." | ||
| fi | ||
|
Comment on lines
+79
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The annotation is gated on Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| exit "$push_status" | ||
| fi | ||
| else | ||
| echo "Applying versioned migrations (db:migrate)" | ||
| bun run ./scripts/migrate.ts | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capturing into
push_output="$(…)"holds all stdout/stderr in memory and releases it only after the process exits. For a quick schema push this is fine, but ifdb:pushhangs (e.g. waiting on a connection) the GitHub Actions log stays blank until the step times out — there's no streaming visibility. Consider adding a timeout flag (e.g.--timeoutif drizzle-kit supports it) or at least a note that live output is unavailable while this step is running.