Running drizzle migrations for my DB before Next.js starts on Vercel

I am trying to do things properly here and not run drizzle-kit migrate locally while pointing to my production DB. While searching I did find this previous topic, but unfortunately it does not answer the question that was asked and due to it being asked almost a year ago, the topic is closed.

I have a command in my package.json that is "db:migrate": "drizzle-kit migrate" and I thought that maybe if I did ”start”: “pnpm db:migrate && next start” that it would run those migrations beforehand. However, after pushing that change to my branch, looks like that actually isn’t the case. That is even the solution that gpt-help in the Next.js discord suggests as well.

So apparently adding drizzle-kit migrate right before next build is the way to go.

2 Likes

Thanks for coming back with a solution, James! :smiley:

1 Like