N
Neon•2y ago
sensitive-blue

Is the branching feature avaliable in vercel + neon + drizzle to run migrations?

I am using drizzle as my ORM in my nextJS project deployed on vercel and I would love to use the branching feature for development workflow but I can't find a way to run migrations. Neon already creates me a database per vercel pre-view but is not running any actions related to migrations, in the documentation it references using Prisma, is there something I can use with drizzle?
6 Replies
absent-sapphire
absent-sapphire•2y ago
Hey! If you'd like to avoid a dedicated CI setup, you can modify the build script in your package.json to use the drizzle-kit CLI to perform your migration. The end result might be a build script similar to this if you already have the migration files generated:
drizzle-kit push:pg && next build
drizzle-kit push:pg && next build
absent-sapphire
absent-sapphire•2y ago
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
sensitive-blue
sensitive-blueOP•2y ago
Thanks evan! this was really helpfull
absent-sapphire
absent-sapphire•2y ago
You're weclome! Oh, and you could define a migrate script in package.json if it's more that just drizzle-kit push:pg. Then your build can be npm run migrate && next build I actually just started using Drizzle for a small project the other day, so I'll be learning too 🙂
correct-apricot
correct-apricot•2y ago
@ShinyPokemon, prior to running the migrate script, I assume we're supposed to use the drizzle-kit generate command to first generate the new migration correct? I think if we just ran npm run migrate && next build we wouldn't have the latest changes. Or should generating the file just be done before pushing? Do you have any recommendations?
absent-sapphire
absent-sapphire•2y ago
Yes, you should check in the results of generate. This way all the mirgations are tracked in Git 🙂

Did you find this page helpful?