pscale deploy-request, branch and connect in CI
pscale branch creates a schema branch, pscale deploy-request opens and deploys a safe schema change, and pscale connect proxies a local connection to a branch.
PlanetScale ships schema changes through deploy requests rather than direct ALTERs. The CLI drives that flow, which fits naturally into CI.
What it does
pscale branch create makes a development branch of the database. pscale deploy-request create opens a request to merge a branch's schema into the base, and pscale deploy-request deploy applies it with no-downtime rollout. pscale connect proxies a local port to a branch for running migrations.
Common usage
# service token auth via env vars in CI
export PLANETSCALE_SERVICE_TOKEN_ID=xxx PLANETSCALE_SERVICE_TOKEN=yyy
pscale branch create my-db add-index --org my-org
pscale deploy-request create my-db add-index --org my-org
pscale deploy-request deploy my-db 42 --org my-orgOptions
| Command / flag | What it does |
|---|---|
| branch create <db> <branch> | Create a schema branch |
| deploy-request create <db> <branch> | Open a deploy request |
| deploy-request deploy <db> <number> | Deploy the request |
| connect <db> <branch> | Proxy a local connection to a branch |
| --org <name> | Target organization |
| PLANETSCALE_SERVICE_TOKEN_ID / _TOKEN | Service token env vars for CI auth |
In CI
Set PLANETSCALE_SERVICE_TOKEN_ID and PLANETSCALE_SERVICE_TOKEN so the CLI authenticates without the interactive pscale auth login browser flow, and pass --org since a service token can span orgs. pscale connect runs until killed; background it, run migrations against the local port, then kill it.
Common errors in CI
"Error: not authenticated, please run pscale auth login" means the service token env vars are unset. "Error: required flag(s) \"org\" not set" means --org is missing (service tokens have no default org). "branch already exists" means a leftover branch from a prior run.