These scripts are designe for a "staging" branch on PlanetScale.
After creating a new database, create that staging
branch on PlanetScale.
# Creating the app + branch $ pscale db create <APP> --region <REGION> $ pscale branch create <APP> staging
Note: You many also need to switch organisation with
pscale org switch <ORGANIZATION_NAME>
.
Then update package.json
to the following:
{ "scripts": { "pscale:migrate": "NODE_ENV=production dotenv-flow npx prisma db push --preview-feature", "pscale:connect": "NODE_ENV=development dotenv-flow pscale connect wol-dev staging --port 3309" } }
Run npm run pscale:connect
in one terminal and npm run pscale:migrate
in another. This will bring things up to date if successful.
For seeding, you can run NODE_ENV=production dotenv-flow npx prisma db seed
.
The following can be used to promoto a database branch.
$ pscale branch promote <DATABASE_NAME> <BRANCH_NAME> # ...
So to promote staging:
$ pscale branch promote <DATABASE_NAME> staging # ...