Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Output buffering silences real-time logs

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 if db:push hangs (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. --timeout if drizzle-kit supports it) or at least a note that live output is unavailable while this step is running.

Comment on lines +76 to +77

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Output buffering hides progress for long-running push

Because db:push output is captured in full before echo "$push_output" prints it, the CI log shows nothing until the command finishes. For a quick push this is fine, but against a large schema the step can appear hung for minutes with no feedback. Consider using a tee approach (e.g., a temp file) to stream output in real time while still being able to inspect it after the fact.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Brittle error-string match

The annotation is gated on grep -q 'Interactive prompts require a TTY', which is a string from hanji's internals. If drizzle-kit upgrades hanji and the message changes (e.g. to "requires a TTY terminal" — already seen in the PR description itself vs the exact string in the grep), the check silently misses, the job still fails correctly, but the helpful annotation is never emitted. The failure mode is quiet degradation of the diagnostic, not a broken workflow, but it's worth documenting the expected string or widening the pattern to 'TTY'.

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
Expand Down
Loading