VSchema overview
Each Vitess cluster can have one or more keyspaces. For unsharded databases, there is a 1:1 relationship between a keyspace and a database within MySQL. For sharded databases, a single keyspace can map to multiple MySQL databases under the hood. Each keyspace in your PlanetScale database has an associated VSchema. The VSchema contains information about how the keyspace is sharded, sequence tables, and other Vitess schema information.Viewing VSchema
In order to view your VSchema, first go to the “Branches” tab in the PlanetScale app.


Modifying VSchema
You must have a sharded keyspace in order to make VSchema changes. If you have a database with at least one sharded keyspace, you can modify its VSchema either in the Cluster configuration tab in the dashboard, from the pscale CLI, or usingALTER VSCHEMA ...
commands.
Using the Cluster configuration page
We do not recommend modifying the VSchema directly on your production branch. In fact, it is not possible to do if you have safe migrations enabled (as recommended). Instead, to modify the VSchema, you should first create a new development branch. Once you have your branch ready, follow these steps:1
To update in the cluster configuration panel, select your new development branch from the dropdown at the top, and then select the keyspace below that has the VSchema you’d like to modify.
2
Next, click the tab labeled “VSchema”.
3
Modify the VSchema configuration JSON file as needed. Refer to the VSchema documentation for more information about the available options.
4
When finished, click “Save changes”. We will validate your VSchema, and if it is valid, the changes will be saved. If there are errors, we will warn you here to change them before saving.
5
Go back to your “Branches” tab and click on the development branch that you modified. You should see a note on the right that says “Updated VSchema configuration” which lets you know the VSchema(s) for this branch has been modified.
6
From here, go through the normal deploy request process to deploy this change to production.
Using ALTER VSchema
PlanetScale recommends making all such modifications in a development branch.
When ready, you can make a deploy request to get the changes into production.
Consider the following database with two keyspaces.

sharded
is a sharded keyspace with two shards and tweeter
is unsharded.
Also note that safe migrations are enabled.
In order to make a VSchema change for the production branch in this configuration, we first must create a new branch.
We’ll call it add-tweets

tweets
in the sharded keyspace and also update the VSchema.


add-tweets
branch.
Here, you will be presented with a diff of both the VSchema and schema changes:


WarningYou can only use
ALTER VSCHEMA ...
commands in branches that have at least one sharded keyspace.
If you do not, you will get an error message when attempting to execute ALTER VSCHEMA ...
.