Type-Safe Access,
Limitless Scale with
Prisma & PlanetScale

Query data from PlanetScale with Prisma – a next-generation ORM for Node.js and TypeScript.

What is Prisma?

Prisma is an open-source ORM that drastically simplifies data modeling, migrations, and data access for SQL databases in Node.js and TypeScript.

// Creating a new record
await prisma.user.create({
firstName: “Alice”,
email: “alice@prisma.io”
id firstName email
1 Bobby bobby@tables.io
2 Nilufar nilu@email.com
3 Jürgen jums@dums.edu
4 Alice alice@prisma.io

How Prisma and PlanetScale fit together

PlanetScale is a MySQL-compatible, serverless database powered by Vitess, which is a database clustering system for horizontal scaling of MySQL. PlanetScale brings many of the benefits of serverless to the database world, with limitless scaling, consumption based pricing, zero-downtime schema migrations, and a generous free tier.

Prisma is an open-source ORM that integrates seamlessly with PlanetScale and supports the full development cycle. Prisma helps you define your database schema declaratively using the Prisma schema fetch data from PlanetScale with full type safety using Prisma Client. Used together, you get all the established benefits of relational databases in addition to a modern developer experience, type safe querying, zero ops, and infinite scale.

The Prisma schema

The Prisma schema uses Prisma's modeling language to define your database schema. It makes data modeling easy and intuitive, especially when it comes to modeling relations.

Evolving your database schema is simple: you update the data model in your Prisma schema, create a database branch on PlanetScale, and run prisma db push apply schema changes.

// Define the `User` table in the database
model User {
id String @id @default(cuid())
email String @unique
password String
name String?
posts Post[]
// Define the `Post` table in the database
model Post {
id String @id @default(cuid())
title String
content String?
authorId String
author User @relation(fields: [authorId], references: [id])

“PlanetScale & Prisma is an unrivaled combination, bringing a supreme developer experience and proven scalability.”

Sam LambertSam Lambert -
CEO of PlanetScale

Why Prisma and PlanetScale?

Non-blocking schema changes

PlanetScale provide a schema change workflow that allows you to update and evolve your database schema without locking or causing downtime for production databases.

Intuitive data modeling

Prisma's modeling language is declarative and lets you intuitively describe your database schema.

Type-safe database client

Prisma Client ensures fully type-safe database queries with benefits like autocompletion - even in JavaScript.

Built for serverless

Avoid the pitfalls of managing servers and deploy your Prisma & PlanetScale project to serverless runtimes for zero ops and limitless scalability.

Easy database migrations

Map your Prisma schema to the database so you don't need to write SQL to manage your database schema.

Filters, pagination & ordering

Prisma Client reduces boilerplates by providing convenient APIs for common database features.


Prisma & PlanetScale Best Practices

In this video, Daniel guides through everything you need to know when using Prisma with PlanetScale. Learn more about referential integrity and how to operate without foreign key constraints, migration workflows with Prisma and PlanetScale using the prisma db push command, and fefining indices on relation scalars (the foreign key fields) for optimal performance.


Database as Code with PlanetScale and Prisma

In this talk from Next.js Conf, Taylor Barnett from the PlanetScale team devles into the idea of practicing databases as code, how you can use PlanetScale with Prisma to define your models in a declarative nature and use branching to experiment with your database in an isolated development environment in a serverless stack.

Our Prisma & PlanetScale Resources

Using Prisma with PlanetScale

This document discusses the concepts behind using Prisma and PlanetScale, explains the commonalities and differences between PlanetScale and other database providers, and leads you through the process for configuring your application to integrate with PlanetScale.

Scaling Databases For Serverless World: Chat With Sugu Sougoumarane

Today, Vitess is the default database for scale at Slack, Roblox, Square, Etsy, GitHub, and many more. But how did it get here? From its creation at YouTube to the database that powers PlanetScale, a serverless database platform, Taylor and Sugu will dive into Vitess' creation, why MySQL, what makes Vitess so powerful, and the different ways it is a great fit for developers building serverless applications.