DEV Community

Arhan Khan
Arhan Khan

Posted on

PlanetScale for Beginners: MySQL That Branches Like Git

PlanetScale is a MySQL-compatible database platform built on Vitess, the technology that powers YouTube's databases. Its headline idea is simple: your database gets branches, just like your code. You test a schema change on a branch, review it, and merge it — without ever running a risky migration directly on production.

How does it work? You create a database in the PlanetScale console, and you connect to it with a normal MySQL connection string. When you want to change the schema, you create a branch, make your changes there, and open a deploy request. PlanetScale checks the change for problems, and you merge it when it is safe.

# Install the CLI and connect to your database
brew install planetscale/tap/pscale
pscale auth login
pscale database create my-app --region us-east
pscale shell my-app main
Enter fullscreen mode Exit fullscreen mode
-- It is MySQL — your existing SQL works
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  email VARCHAR(255) UNIQUE NOT NULL
);

INSERT INTO users (name, email) VALUES ('Arhan', 'arhan@example.com');
SELECT * FROM users;
Enter fullscreen mode Exit fullscreen mode
// Connect from Node.js with the standard MySQL driver
import mysql from 'mysql2/promise';

const connection = await mysql.createConnection(process.env.DATABASE_URL);
const [rows] = await connection.execute('SELECT * FROM users');
console.log(rows);
Enter fullscreen mode Exit fullscreen mode

PlanetScale is great for beginners because the free tier is generous and the workflow teaches you a professional habit early: never change production directly. The dashboard also shows your queries and schema in a clean interface, so you can see what your app is actually doing.

When should you use PlanetScale? For apps that need MySQL, especially when more than one person works on the database. It is a good fit for products that expect to grow, because Vitess was designed for databases that outgrow a single server.

The limits are worth knowing. PlanetScale has opinions: foreign keys are not supported in the traditional way, so you enforce relationships in your application code or with their newer foreign key support. And if your app is tiny and will stay tiny, a plain MySQL or SQLite database is simpler.

Start today: create a free PlanetScale database, make a table, and insert one row. Then create a branch, add a column there, and see how branching feels — it is the whole idea in one experiment.

Top comments (0)