Overview
TipTo make non-blocking schema changes in PlanetScale, you’ll first need a basic understanding of
branching, the core PlanetScale feature that provides schema changes. Our
branching page is a great place to start.
Adding columns to large tables with PlanetScale is safe!
Create, drop, and alter statements, also known as Data Definition Language (DDL), are used for making schema changes in a database table. PlanetScale enables developers to make schema changes without the fear of dropping columns, locking tables, causing downtime in their app, etc. PlanetScale also prevents schema changes with conflicts from being migrated and handles schema changes from multiple teammates. A user doesn’t have to wait to find out if their changes will be rejected, they learn as they add the change to the queue.How do I make non-blocking schema changes with PlanetScale?
In order to make non-blocking schema changes, you must enable safe migrations on your production branch. Without safe migrations enabled, your schema changes will run directly on your production branch, which can lead to table locking. When safe migrations are enabled on a branch, all schema changes must occur on a database branch. (A database branch is a separate database with a copy of the production branch’s schema.) At a high level, this is what happens during the non-blocking schema change process in PlanetScale:1
You create a development branch.
2
You test your changes on this branch before attempting to apply the changes to the production branch. (i.e., You made some changes to the database you wish to deploy to the production database.)
3
You open a request to deploy your changes to the base branch, the production branch.
4
PlanetScale verifies that your schema changes are safe to be deployed to production. If there are any issues or schema conflicts, you’ll be shown the errors.
5
You click
Deploy changes
. Your deploy is added to a queue and run immediately or when existing deploys are complete.6
Your deployment makes it to the base branch, and you can now see your schema changes in production.
NotePlanetScale makes sure not to exhaust your resources; the deployment may be throttled to avoid any impact on
production queries.

PlanetScale workflow
The PlanetScale command-line tool (CLI) runs an interactive shell equipped with many commands designed to make the database management workflow easier for developers. A basic non-blocking schema change workflow in PlanetScale might look like this:1
Create a database:
2
Create a development branch:
3
Make a schema change on this branch:Here is a sample CREATE table schema change you could try using:
TipA schema change is any change you make to the tables in your database environment created within the PlanetScale branch. (i.e., create, drop, and alter statements)
WarningYou can only apply direct schema changes to branches without safe migrations enabled.
4
Test changes on branch locally.
5
Create a deployment request by running:
6
Fix any schema conflicts.PlanetScale displays the difference between what is currently in the base branch and your development branch. Go back to Step 3 of the workflow and test out new schema changes to fix the schema conflict. If you did not encounter any schema conflicts, you’re ready for Step 7.
7
Deploy the deploy request.
-
To deploy the deploy request created in Step 5, run the following command:
-
To find your
deploy-request-number
, simply run:
NUMBER
and use that digit as your deploy-request-number
.Limitations
If you want to make schema changes containing foreign key constraints, enable foreign key constraint support for your database in the database settings page. PlanetScale doesn’t support directRENAME
for columns and tables. Learn why and how to rename tables or columns in this tutorial.