Skip to content

Korzun/prisma-migrate-planetscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Prisma Migrate for PlanetScale

Prisma and PlanetScale have some helpful documentation to get you started. What they don't offer are examples of how a migration might be run in production. This repo aims to add some ready-made free-to-use scripts to get you migratin'.

Existing Documentation

If this is your first time integrating Prisma with PlanetScale, follow their existing documentation. When you're ready to start migrating in production, then come back here.

Pre-Requisites

To use the contained scripts, you'll need to create a service token using the Planetscale CLI and give it the following permissions for the database you want to migrate. Note: You must complete this step using the CLI. It seems the PlanetScale Web UI is unreliable at setting these permissions.

  • connect_branch
  • create_branch
  • create_deploy_request
  • delete_branch
  • read_branch

Gotchas'

  • Setting PlanetScale service token permissions via the Web UI is unreliable. The permissions will appear, but they won't work with the CLI.
  • Repeatedly creating and deleting a PlanetScale branch of the same name will introduce CLI connection issues. These scripts use the date or a short-sha to dodge this issue.
  • The PlanetScale's CLI creates an environmental variable DATABASE_URL when using the pscale connect command. This variable will overwrite any existing variable of the same name. This behavior can cause some head-scratching.
  • The PlanetScale CLI doesn't allow pull-requests to be created despite having the correct permissions.
  • The PlanetScale CLI connect command doesn't wait for a newly created branch to be available, it just fails to connect. These scripts wait 10 seconds to side-step this issue.
  • The PlanetScale CLI won't install on node:lts-alpine as it reports as musl-linux-amd64 instead of amd64. Using the dpkg --force-architecture flag works.

About

Automate Prisma Migrations on Planetscale

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published