Skip to content

Commit 1cf9029

Browse files
committed
Ensure Vercel applies Prisma migrations before build
1 parent 5fd7469 commit 1cf9029

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,11 @@ Creating a dedicated simulator workspace:
400400
- `NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in`
401401
- `NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up`
402402
- In Clerk Dashboard, allow both URLs on the deployed origin.
403-
6. Run Prisma migrations against your production database:
404-
- Either via CI/CD step: `npx prisma migrate deploy`
405-
- Or manually once after deploy
403+
6. Vercel deploys should use the repo build command `npm run vercel-build`:
404+
- This runs `npm run db:generate`
405+
- Then `npm run db:deploy`
406+
- Then `npm run build`
407+
- If the Vercel dashboard overrides the build command, set it to `npm run vercel-build`
406408
7. Configure Stripe webhook to the Vercel domain.
407409
8. Configure Twilio phone number webhooks (or buy the number through the app after deploy).
408410
- Helper: `npm run webhooks:print` (redacts the shared token by default)
@@ -439,8 +441,9 @@ Use this checklist before sending paid traffic to `callbackcloser.com` or allowi
439441
- `npm run typecheck`
440442
- `npm run build`
441443
3. Confirm Vercel production env vars match `docs/PRODUCTION_ENV.md`.
442-
4. Apply production Prisma migrations:
443-
- `npx prisma migrate deploy`
444+
4. Confirm the deploy path applies Prisma migrations before runtime:
445+
- repo build command: `npm run vercel-build`
446+
- exact migration step inside it: `npm run db:deploy`
444447
- optional smoke: `npm run db:smoke`
445448
5. Confirm Stripe production setup:
446449
- live products/prices exist

docs/DB_NEON_PRISMA.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ Recommended:
6969
- Preview uses preview/staging Neon DB URLs (pooled + direct)
7070
- Production uses production Neon DB URLs (pooled + direct)
7171

72+
### Vercel build command
73+
74+
This repo expects Vercel to use:
75+
76+
```txt
77+
npm run vercel-build
78+
```
79+
80+
That script runs, in order:
81+
82+
1. `npm run db:generate`
83+
2. `npm run db:deploy`
84+
3. `npm run build`
85+
86+
This keeps Prisma Client generation explicit and applies additive Prisma migrations through `DIRECT_DATABASE_URL` before `next build` completes.
87+
7288
## Common Mistake to Avoid
7389

7490
Using the pooled `-pooler` URL for Prisma migrations can cause migration problems or connection behavior issues. Keep migrations on `DIRECT_DATABASE_URL` (direct endpoint) and runtime on `DATABASE_URL` (pooled endpoint).

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8+
"vercel-build": "npm run db:generate && npm run db:deploy && npm run build",
89
"start": "next start",
910
"test": "tsx --test tests/*.test.ts",
1011
"test:twilio": "tsx --test tests/twilio-*.test.ts",

vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"framework": "nextjs",
3-
"buildCommand": "npm run build"
3+
"buildCommand": "npm run vercel-build"
44
}

0 commit comments

Comments
 (0)