PlanetScale deployments when using T3, prisma, and vercel
Hey friends! I'm working on a T3 based app that I have been working on for a while now, and I'm trying to get the production environment setup.
I would like to use vercel to deploy along with PlanetScale for the database, but I'm finding a lack of information on how to deal with migrations on new deployments.
My ideal scenario is that when I merge anything into my main branch on GitHub, when vercel deploys the new site it also migrates any prisma schema changes to the main PlanetScale branch. However I can't seem to find any good information on how to automate this. At the moment it seems like I need to create a planetscale branch from the cli, create a deploy-request, accept that request, then merge my PR, so vercel deploys. This just doesn't seem like the "right" way to do it. Unfortunately in every prisma/planetscale video I've watched, they always explain the initial setup, but never anything about what to do after that first deployment. I did also watch Theo's
FROM 0 TO PROD FOR $0 video, but unless I missed something, he's just using prisma db push before uploading his code and is also using the dev DB for local development.
Ideally I would also like to have a development DB that is used for vercel preview deployments but that is something I can figure out after I figure out the correct way to deal with the main DB deployments.
I feel like this is a relatively common scenario so I'm quite confused as to why I can't find any information on it, but any help would be greatly appreciated.3 Replies
I'm also trying to figure this out
If you use GitHub, you can build a pipeline yourself, migrate data and set up database connections as necessary.
I do the same, but with a selfhosted Gitlab instance.
Vercel has some pretty amazing guides on this:
https://vercel.com/guides/can-i-use-self-managed-gitlab-with-vercel
Vercel Documentation
Can I use self-managed GitLab with Vercel?
Information about using self-managed GitLab with Vercel to deploy your applications.
If you still can't find, what you're looking for, check out the CLI:
https://vercel.com/docs/cli
Vercel Documentation
Vercel CLI Overview
Learn how to use the Vercel command-line interface (CLI) to manage and configure your Vercel Projects from the command line.