Skip to main content

Getting Started

Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.

The branch command

This command creates and manages Vitess, Postgres, and Neki branches. It also contains the Neki configuration, shard, router, and data-topology commands. Usage:

Available sub-commands

Service token automation: branch

Legend: ✅ supported · 🚫 unavailable · 👤 interactive login only. All sub-commands require --org or PLANETSCALE_ORG.
Setup and commands to avoid: CLI overview · Service tokens
* Flag is required

Sub-command flag descriptions

Some of the sub-commands have additional flags unique to the sub-command. This section covers what each of those does. See the above table for which context.
You can use --region with --restore to restore a backup into another region. --restore-point is available for Postgres and Neki. When you pass --restore-point without --restore, --from is required so the CLI can look up a backup that covers that timestamp.

Available flags

Global flags

Examples

The connections sub-command

Command:
Opens a live view of the branch’s connection activity. It works for Postgres and Vitess branches; for Vitess, pass --keyspace and --shard to target a tablet, or run interactively to select them. See the connections reference, Inspect live Postgres connections, and Inspect live Vitess connections for the full workflow.

Neki configuration commands

Neki infrastructure commands are nested under pscale branch. See Neki cluster configuration and Neki data topology for the workflows behind these commands.

Configuration profiles

create and update accept --cluster-size, --replicas, --postgres-major-version, --postgres-minor-version, --min-storage, --max-storage, --storage-autoscaling, --storage-iops, and --storage-throughput. --postgres-major-version is required when you pass --postgres-minor-version. update also accepts --name and repeatable --parameters namespace.name=value. parameters accepts --namespace, --extension, and --internal. extensions enable and extensions disable toggle an extension that the catalog marks as enablable. maintenance upgrades one or more profiles to the latest image and returns immediately; use pscale branch maintenance run to maintain every profile on the branch. Change lists accept --period, --completed-at, --page, and --per-page.

Shards

--config-profile is required on create and assign. list and show include whether the shard is the authoritative copy from the branch data topology. list accepts --config-profile, --exclude-config-profile, --query, --page, and --per-page. update --display-name "" clears a display name. delete accepts --force.

Routers

create accepts --size and --replicas-per-cell. update also accepts --autoscaling, --max-replicas-per-cell, --target-cpu-utilization, and repeatable --parameters. sizes lists valid router SKUs. Change lists accept --period, --completed-at, --page, and --per-page. delete accepts --force. Connect through a named router with pscale shell --router.

Admin and sidecars

Each Neki branch has one Admin. Each configuration profile has one sidecar. Both are created and deleted with the cluster or profile.
<SIDECAR> is the sidecar ID from sidecar list, or the configuration profile name. Admin update accepts --size and --parameters. admin sizes lists valid Admin SKUs. Sidecar update accepts --parameters. Change lists include a Changes column with the previous and requested size or parameter values, and accept --period, --completed-at, --page, and --per-page.

Data topology and maintenance

data-topology update reads a JSON object from standard input. ls --shards groups the topology by the physical shards that host the data. maintenance run updates every profile on the branch to the latest available image.

Restore a Neki backup

pscale branch create --restore creates a new branch from a backup, the same as pscale backup restore. For Neki, omit --cluster-size to keep the source default profile size. Override individual profiles and routers with repeatable --config-profile and --router flags.
Preview the live source sizes first with pscale backup restore show <DATABASE_NAME> <SOURCE_BRANCH_NAME> <BACKUP_ID>.

The query-patterns sub-command

Command:
List, inspect, and delete existing Query Insights reports for a branch. The download command creates a new report, waits for it to finish generating, and downloads the CSV file. See the query-patterns reference for the full workflow.

The update sub-command

Command:
Renames a branch or changes its deletion protection. Only the flags you pass are sent, and at least one is required.

The extensions sub-command

Command:
Lists the extensions available on a Postgres branch’s cluster image. This is the catalog the image can load, not the result of CREATE EXTENSION. Preload libraries are configured with pscale branch resize --parameters. See Postgres extensions.

The switchover sub-command

Command:
Moves the primary of a Postgres branch to a replica. With --candidate, the named replica is promoted; without it, an eligible replica is selected automatically. On a branch without replicas, the single instance is restarted in place instead. See Switchovers for the full workflow. List past switchovers or show one by id. switchover list supports --page and --per-page.

The list sub-command with --web flag

Command:
Output: Opens the Branches page, <https://app.planetscale.com/org/database/branches>, in browser.

The parameters sub-command

Command:
Lists the configuration parameters of a Postgres branch, including their current values, defaults, allowed ranges, and whether changing them requires a restart. Use --namespace to limit the output to a single namespace such as pgconf, pgbouncer, or patroni.

The resize sub-command

Command:
Creates a change request for a Postgres branch. A single change request can update the cluster size (--cluster-size), the number of replicas (--replicas), and configuration parameters (--parameters, repeatable) together. With --wait, the command polls until the change request completes; without it, the command returns immediately and you can follow up with resize status. Some parameters require a database restart to take effect; the command tells you which ones before the change is applied. Command:
Shows the latest change request for the branch, including its state (queued, pending, resizing, completed, or canceled) and what it changes. Command:
Cancels the queued change request for the branch. Only change requests that have not started being applied can be canceled.

The vtgate sub-command

Command:
Shows the current VTGate size, count, and autoscaling settings for a Vitess branch. Command:
Queues a VTGate resize for a Vitess production branch. Pass at least one of --vtgate-size, --vtgate-count, --vtgate-max-count, --vtgate-autoscaling, or --vtgate-target-cpu-utilization. Development branches cannot be resized. See the VTGate documentation for size defaults, autoscaling limits, and pricing. Command:
Shows the latest VTGate resize request for the branch. Command:
Cancels a queued VTGate resize. Only resize requests that have not started being applied can be canceled.

The diff sub-command

Command:
Output:
This will return the diff against the parent branch.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.