NeonN
Neon17mo ago
24 replies
urgent-maroon

Migration Workflows

We are using Vercel, Neon, Prisma and GitHub. I've set up the Neon Vercel integration, as well as the Github Vercel integration, and everything's working well.

Our workflow right now is:

1. Create a branch off of
main
. This causes Vercel and Neon to spin up a branch specific environment.
2. Push changes to the branch. Pull the env vars with vercel env pull --environment=preview --git-branch=$branch_name for local dev.
3. Once the merged into
main
, CI/CD pushes everything to production.

What's a good flow for managing migrations in this setup? For branch specific migrations, we've just been running them ourselves locally with npx prisma migrate dev, and then a manual npx prisma migrate deploy for production. Have any of you set up good Github Actions/Workflows for this?

One challenge is it's not clear to me how to programmatically get the database URL for a branch.

I found https://neon.tech/docs/guides/neon-github-integration and https://github.com/neondatabase/preview-branches-with-vercel/tree/main but since the integration already creates the branch, it's not clear how to fetch that info.
Neon
The Neon GitHub integration connects your Neon projects to corresponding GitHub repositories, helping you incorporate your database into your developer workflow. For example, create a database branch ...
The Neon GitHub integration - Neon Docs
GitHub
Example project that shows how you can create a branch for every preview deployment on Vercel using GitHub actions - neondatabase/preview-branches-with-vercel
Was this page helpful?