Repository navigation
fix(db): run prisma migrate deploy on production builds - #22
Merged
Merged
Conversation
Auditing "verification emails not working" turned up a much bigger issue: the 9_notification_preferences migration was merged in PR #18 but had only ever been applied to the local dev database and CI's ephemeral test Postgres, never to the actual production Neon database. `next build` never ran `prisma migrate deploy` — the app's build script only ran `prisma generate` — so every request to /settings (account settings, password change, payout method, email preferences) had been throwing a 500 in production since that PR merged. Applied the missing migration to production directly to fix it now, and changed the build script so this can't silently happen again: `scripts/migrate-if-production.mjs` runs `prisma migrate deploy` only when `VERCEL_ENV=production` (preview and production share one Neon database, so this avoids an unmerged preview branch applying its migration before review). Also centers the "Welcome Back" heading and subtitle on the sign-in card, matching the rest of the auth pages.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audited the full auth flow end-to-end after a report that verification emails weren't sending. Findings:
1. Verification emails: actually working now, root cause was timing. Live testing (real signup, resend, click-through, sign-in, all confirmed via Brevo's delivery events) shows send + resend both work correctly on the current deployment. The
hackvillage.xyzdomain's DNS authentication in Brevo only completed at 04:56 UTC today — any attempts before that would have had degraded or failed deliverability. No code change needed here; verified end-to-end.2. Real bug found:
/settingshas been throwing 500 in production since PR #18. The9_notification_preferencesmigration was merged and applied to the local dev DB and CI's ephemeral test Postgres, butnext build's script only ranprisma generate— neverprisma migrate deploy— so the table was never created on the actual production Neon database. Every request to/settings(account settings, password change, payout method, email preferences) has been crashing withP2021: table does not exist.prisma migrate deployagainst the Neon prod DB) to fix it immediately — confirmed via live testing that/settingsnow loads, password change works and sends its confirmation email, and email preferences save correctly.scripts/migrate-if-production.mjsnow runs as part ofpnpm run build, applyingprisma migrate deployonly whenVERCEL_ENV=production(preview and production share one Neon database, so this avoids an unmerged preview branch mutating prod schema before review).3. Also verified while auditing: signup → verification → click-through → sign-in; forgot-password → reset → sign-in with new password; Google and GitHub OAuth both correctly reach their provider consent screens.
4. Small fix: centers the "Welcome Back" heading/subtitle on the sign-in card, matching the rest of the auth pages.
Test plan
pnpm run typecheck/pnpm run lint— cleanpnpm exec vitest run tests/unit— 98/98 passingpnpm run build— confirms the new build script correctly skips migration locally (VERCEL_ENVunset) and still builds