Getting Started
Make sure to first set up your PlanetScale developer environment. Once you’ve installed thepscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
The move-tables command
Run Vitess MoveTables workflows on a Vitess database branch: copy tables from one keyspace to another, check copy and traffic state, switch reads then writes, and complete or cancel the workflow. Use it to shard tables, change the number of shards, and import an external MySQL database from an external keyspace.
move-tables prints JSON. The output includes a next_steps field with a suggested next command. Use it to see what to run after list or status. Pass --format json when you script move-tables, so progress messages don’t mix with the JSON.
Usage:
pscale branch vtctld move-tables also works.
You must be an Organization Administrator or a Database Administrator of the database to create and change workflows. Service tokens need
read_workflow to list and view workflows, write_workflow to create, start, stop, switch traffic, and complete them, and delete_workflow to cancel them.Available sub-commands
* Flag is required † Pass either--tablesor--all-tables
list also accepts the alias ls.
Sub-command flag descriptions
Write boolean flags with an
=, such as --keep-data=false. A space-separated value such as --keep-data false is read as --keep-data=true.
Available flags
Global flags
Lifecycle
A typical MoveTables run looks like this:- Create the workflow and wait until copy finishes and streams are
Running. - Verify with
pscale branch vtctl vdiff create, thenvdiff showuntil it completes with no mismatches. You can skip VDiff and switch replica traffic directly. - Switch replica traffic with
--tablet-types REPLICA,RDONLY. - Switch primary traffic with
--tablet-types PRIMARY. - Preview cleanup with
complete --dry-run, then complete after you review the result.
status between steps. Each stream’s state is Copying, Running, Lagging, Stopped, or Error. traffic_state values are:
Reads Not Switched. Writes Not SwitchedAll Reads Switched. Writes Not SwitchedReads Not Switched. Writes SwitchedAll Reads Switched. Writes Switched
stop to pause a workflow and start to resume it, for example after it stops on a schema change. Until you complete a workflow, you can switch traffic back with reverse-traffic or cancel it.
You can also follow each workflow on the Workflows page in the dashboard. The page is read-only.
Examples
List MoveTables workflows and get the next command to run:status JSON after replica traffic has switched:
Import from an external keyspace
After you create an external keyspace, move its tables into your PlanetScale keyspace:--keep-data must be true, so the tables in your source database are never dropped:

