Next.js Discord

Discord Forum

How to Automatically Migrate Database on Vercel Deployment?

Answered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
I’m using Next.js hosted on Vercel for production and running locally for development. My PostgreSQL database is hosted on NeonDB for production and in a local Docker container for dev. I’m also using DrizzleORM for ORM and Drizzle Kit for migrations.

I want to automatically run database migrations when deploying to Vercel, similar to a pre-build hook.

Is this possible to do?
Answered by @ts-ignore
just update the build or start script of your application to run the migrations first and then the actual command after
View full answer

3 Replies

just update the build or start script of your application to run the migrations first and then the actual command after
Answer
"build":"drizzle-kit ... && next build"
Sun bearOP
that is genius, thank you!