Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide to using Prisma with PlanetScale #2708

Merged
merged 50 commits into from
Jan 27, 2022
Merged
Changes from 7 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3a4fdbf
stub file for new PS guide
Jan 12, 2022
5492257
a few more bits added to draft
Jan 17, 2022
f0b45e2
Delete 500-planetscale
tanberry Jan 17, 2022
3006d0c
added links to Getting Started docs
Jan 18, 2022
a7fa364
Merge branch 'main' into planetscale-guide
tanberry Jan 18, 2022
67203f5
sync base with upstream, Merge branch 'planetscale-guide' of https://…
Jan 18, 2022
122c7f2
Update 500-planetscale-guide.mdx
Jan 20, 2022
916fbfc
Update 500-planetscale-guide.mdx
Jan 20, 2022
4d792c1
Update 500-planetscale-guide.mdx
Jan 20, 2022
e7c6281
Update 500-planetscale-guide.mdx
Jan 20, 2022
8d99f46
Update 500-planetscale-guide.mdx
Jan 20, 2022
b7f279f
Update 500-planetscale-guide.mdx
Jan 20, 2022
300d4a5
Rename PlanetScale guide filename
Jan 21, 2022
aca347c
Update 500-using-prisma-with-planetscale.mdx
Jan 21, 2022
c2218b2
Update 500-using-prisma-with-planetscale.mdx
Jan 21, 2022
65adb21
Update 500-using-prisma-with-planetscale.mdx
Jan 21, 2022
d2e05f7
Update 500-using-prisma-with-planetscale.mdx
Jan 21, 2022
1a8b953
Update 500-using-prisma-with-planetscale.mdx
Jan 24, 2022
ea13936
Update 500-using-prisma-with-planetscale.mdx
Jan 24, 2022
bb0b697
Update 500-using-prisma-with-planetscale.mdx
Jan 24, 2022
e445676
Update 500-using-prisma-with-planetscale.mdx
Jan 24, 2022
e59b15c
Update 500-using-prisma-with-planetscale.mdx
Jan 24, 2022
2ad0066
Update PlanetScale guide and error reference
Jan 24, 2022
af5b9eb
Update gatsby-config.js
Jan 25, 2022
5f91cca
Add details on PlanetScale production branches
Jan 25, 2022
96993c6
Update content/300-guides/050-database/500-using-prisma-with-planetsc…
keerlu Jan 25, 2022
d473032
Update content/300-guides/050-database/500-using-prisma-with-planetsc…
keerlu Jan 25, 2022
f98b866
Update 500-using-prisma-with-planetscale.mdx
Jan 25, 2022
b87cca1
Merge branch 'planetscale-guide' of https://github.com/prisma/docs in…
Jan 25, 2022
50efde6
Update 500-using-prisma-with-planetscale.mdx
Jan 25, 2022
e3a0197
Update 500-using-prisma-with-planetscale.mdx
Jan 25, 2022
380d56c
Renumber PlanetScale guide filename
Jan 25, 2022
6123b90
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
585a7b5
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
e87cdd0
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
a218b17
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
f14f023
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
7749e23
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
2327b47
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
677c0be
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
80a7706
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
e49b3cf
Update content/300-guides/050-database/850-using-prisma-with-planetsc…
keerlu Jan 25, 2022
829a9ca
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
ac7cc2f
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
7b08592
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
a2a55e9
Update 850-using-prisma-with-planetscale.mdx
Jan 25, 2022
bdc3136
Update 850-using-prisma-with-planetscale.mdx
Jan 26, 2022
d8ec33d
Update 850-using-prisma-with-planetscale.mdx
Jan 26, 2022
871c1cc
Update 850-using-prisma-with-planetscale.mdx
Jan 26, 2022
933876d
Update 850-using-prisma-with-planetscale.mdx
Jan 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
89 changes: 89 additions & 0 deletions content/300-guides/050-database/500-planetscale-guide.mdx
@@ -0,0 +1,89 @@
---
keerlu marked this conversation as resolved.
Show resolved Hide resolved
title: 'Prisma with PlanetScale'
metaTitle: 'Prisma with PlanetScale'
metaDescription: 'Guide on using Prisma with PlanetScale'
tocDepth: 2
toc: true
---

<TopBlock>

Prisma and PlanetScale together provide a development arena that optimizes rapid, type-safe development of data access applications, using Prisma's ORM and PlanetScale's highly scalable MySQL-based platform.

</TopBlock>

## About using Prisma with PlanetScale

This document discusses the concepts behind using Prisma and PlanetScale, explains some important concepts and considerations on the commonalities and differences between PlanetScale and other dtabase providers, and leads you through the process for configuring your application to implement PlanetScale.

Two main benefits of using Prisma with PlanetScale are:

- enterprise scalability

- !!use Jan's content

- support non-blocking schema changes
- !!use Jan's content

Watch our video on [Best Practices when using Prisma with PlanetScale](https://www.youtube.com/watch?v=iaHt5_hg44c).

## Commonalities with other database providers

Many aspects of using Prisma with PlanetScale are just like using Prisma with any other database.

- You still model your database with Prisma Schema Language
- You can use `mysql` as the provider that you define in your schema, plus the [connection string PlanetScale provides you](https://docs.planetscale.com/concepts/connection-strings)
- Use Introspection for existing projects if you already have a database schema in PlanetScale
- Use `db pull` to migrate your database schema
- Use Prisma Client in your application to talk to the database server at PlanetScale

## Differences to consider

There are important considerations to be aware of when working with PlanetScale, such as how to handle referential integregrity, because PlanetScale does not enforce foreign key constriants.

Referential integrity is managed ....

- Prisma emulates “missing” referential integrity on PlanetScale in Prisma Client
.....

- branches + deploy requests

- [https://docs.planetscale.com/concepts/branching](https://docs.planetscale.com/concepts/branching)

- **Migrations** with Prisma when using multiple branches:

- ⇒ Recommend `prisma db push` instead of `prisma migrate`
- TODO Reasoning

## Additional considerations

- Defining indices on foreign keys (@@index)
- using db push (migrate has no value)
- Use expand and contract for “breaking changes” (renames aren’t supported anyways)

> **No schema changes on your production database**

- ⇒ _have_ to use branches and deploy requests when working with production branch

> **No data copying between branches**

- Migrate needs migration table to work
- ⇒ enable migration table copy in settings on PS

-- defining an index on an implicit many-to-many relation... creating indices for relation scalars with referentialIntegrity set to Prisma (and the proposal: https://github.com/prisma/prisma/issues/10611)

## How to implement Planetscale

!!sentence about how you can use it in either PDP or with ORM

### PlanetScale and the ORM....

The fastest way to start using PlanetScale with the Prisma ORM is to refer to our Getting Start documentation:

- [Start from scratch](https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-planetscale)

- [Add to existing project](https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-planetscale)

### PlanetScale on the Prisma Data Platform

TODO Description of the integration and its benefits... eventually we can link to separate Platform docs.