> pscale
the PlanetScale CLI — branch databases like code, ship schema changes through deploy requests, and manage MySQL & Postgres from the terminal
// setup & auth
8 commandsInstall the PlanetScale CLI
$ brew install planetscale/tap/pscaleLog in to PlanetScale
$ pscale auth loginCheck whether you're authenticated
$ pscale auth checkLog out and revoke the session
$ pscale auth logoutList and inspect your organizations
$ pscale org listSwitch the active organization
$ pscale org switch my-orgRun one command against another org
$ pscale database list --org other-orgSet up shell completion
$ pscale completion zsh > "${fpath[1]}/_pscale"// databases & regions
8 commandsCreate a MySQL database
$ pscale database create mydb --region us-eastCreate a Postgres database
$ pscale database create mydb --engine postgresql --region gcp-asia-northeast3 --replicas 2List all databases in your org
$ pscale database listInspect a database or open it in the browser
$ pscale database show mydbDelete a database
$ pscale database delete mydbList available regions
$ pscale region listFind the lowest-latency region from your machine
$ pscale pingList available cluster sizes
$ pscale size cluster list// branches
14 commandsCreate a development branch
$ pscale branch create mydb add-users-tableBranch from another branch
$ pscale branch create mydb add-users-index --from add-users-tableCreate a branch with production data
$ pscale branch create mydb test-migration --seed-dataScript branch creation and wait until ready
$ pscale branch create mydb ci-check-$GITHUB_RUN_ID --waitList all branches of a database
$ pscale branch list mydbShow branch details
$ pscale branch show mydb add-users-tableView the schema of a branch
$ pscale branch schema mydb add-users-tableDiff a branch against its parent
$ pscale branch diff mydb add-users-tableLint a branch's schema for errors
$ pscale branch lint mydb add-users-tablePromote a branch to production
$ pscale branch promote mydb mainDemote a production branch to development
$ pscale branch demote mydb old-prodEnable safe migrations on a production branch
$ pscale branch safe-migrations enable mydb mainDelete a branch
$ pscale branch delete mydb add-users-tablePin your project to a branch
$ pscale branch switch add-users-table --database mydb// connect & shell
9 commandsOpen a SQL shell to a branch
$ pscale shell mydb mainOpen a read-only shell
$ pscale shell mydb main --role readerTunnel a branch to localhost
$ pscale connect mydb add-users-tableTunnel on a specific port
$ pscale connect mydb add-users-table --port 3309Launch your app with an injected DATABASE_URL
$ pscale connect mydb dev-branch --execute 'pnpm dev'Watch live connection activity
$ pscale branch connections top mydb mainList connections and queries on a branch
$ pscale branch connections show mydb main --format jsonKill a runaway query or connection
$ pscale branch connections kill mydb main <query-id> --queryKill a stuck Postgres transaction
$ pscale branch connections kill-transaction mydb main <transaction-id>// passwords & credentials
6 commandsCreate a branch password for your app
$ pscale password create mydb main my-app-prodCreate a read-only password
$ pscale password create mydb main metabase-ro --role readerCreate a password that expires
$ pscale password create mydb main debug-session --ttl 2hList branch passwords
$ pscale password list mydb mainDelete a branch password
$ pscale password delete mydb main <password-id>Renew an expiring branch password
$ pscale password renew mydb main <password-id>// postgres roles & traffic
9 commandsCreate a role for a Postgres branch
$ pscale role create mydb main analytics-ro --inherited-roles pg_read_all_dataCreate an admin role
$ pscale role create mydb main migration-admin --inherited-roles postgresCreate a temporary role with a TTL
$ pscale role create mydb main hotfix-debug --inherited-roles pg_read_all_data --ttl 1hList roles on a Postgres branch
$ pscale role list mydb mainReset a role's password
$ pscale role reset mydb main <role-id>Reset the default postgres role credentials
$ pscale role reset-default mydb mainDelete a role and reassign what it owns
$ pscale role reassign mydb main <role-id> --successor app-rwCap query load with a traffic budget
$ pscale traffic-control budget create mydb main --name batch-jobs --capacity 2000 --rate 20 --mode warnMatch queries to a traffic budget with rules
$ pscale traffic-control rule create mydb main <budget-id> --fingerprint 'select * from analytics_events where ...'// deploy requests
11 commandsOpen a deploy request for schema changes
$ pscale deploy-request create mydb add-users-tableTarget a specific base branch
$ pscale deploy-request create mydb add-users-table --into stagingList deploy requests
$ pscale deploy-request list mydbShow a deploy request's status
$ pscale deploy-request show mydb 12Review the schema diff of a deploy request
$ pscale deploy-request diff mydb 12Approve or comment on a deploy request
$ pscale deploy-request review mydb 12 --approveDeploy the schema change
$ pscale deploy-request deploy mydb 12Deploy instantly with ALGORITHM=INSTANT
$ pscale deploy-request deploy mydb 12 --instantGate the schema swap for manual confirmation
$ pscale deploy-request create mydb risky-change --disable-auto-applyRevert a deployed schema change
$ pscale deploy-request revert mydb 12Cancel or close a deploy request
$ pscale deploy-request cancel mydb 12// backups & data
7 commandsCreate a manual backup
$ pscale backup create mydb main --name pre-users-migrationList backups of a branch
$ pscale backup list mydb mainRestore a backup to a new branch
$ pscale backup restore mydb recovery-branch <backup-id>Delete a backup
$ pscale backup delete mydb main <backup-id>Dump a database to local files
$ pscale database dump mydb main --output ./dumpDump only specific tables or schema
$ pscale database dump mydb main --tables users,orders --output ./dumpRestore a local dump into a branch
$ pscale database restore-dump mydb import-branch --dir ./dump// automation & ci
10 commandsCreate a service token
$ pscale service-token create --name deploy-pipelineGrant a service token database access
$ pscale service-token add-access <token-id> create_branch read_branch delete_branch --database mydbAudit and revoke service token access
$ pscale service-token listAuthenticate CI with a service token
$ export PLANETSCALE_SERVICE_TOKEN_ID=<token-id> PLANETSCALE_SERVICE_TOKEN=<token-secret>Get machine-readable output from any command
$ pscale branch list mydb --format json | jq -r '.[].name'Call the PlanetScale API directly
$ pscale api organizations/{org}/databasesPOST to the API with fields
$ pscale api organizations/{org}/databases -F 'name="scratch-db"'Create a webhook for database events
$ pscale webhook create mydb --url https://ci.example.com/hooks/pscale --events branch.ready,deploy_request.openedTest and manage webhooks
$ pscale webhook list mydbList audit logs
$ pscale audit-log list --limit 50