Using Prisma with a PlanetScale database
Problem
UPDATE As of 27.10.2022, the details in this issue are outdated. Refer to https://www.prisma.io/docs/guides/database/using-prisma-with-planetscale for the latest instructions on using Prisma with PlanetScale. Outdated Issue content PlanetScale is a new and interesting cloud database based on MySQL. It's exciting! PlanetScale is a bit different than other MySQL database providers though: 1. No support for foreign keys. This is challenging for Prisma users, as Prisma by default uses foreign keys to express relations. 1. No creation of additional databases using `CREATE DATABASE` but need to use their tooling (web UI or CLI). This can be challenging, as some development commands of Prisma like `prisma migrate dev` create temporary databases in the background. 1. No schema changes on your production database (but make them on branches, then merge the schema changes back). This is challenging for Prisma users, as usually they run Migrations against their database directly via `prisma migrate deploy` or `prisma db push`. --- Here is how you can use Prisma and PlanetScale together anyway: 1. No foreign keys / No Prisma Migrate (`migrate dev` and `db push`) - Problem: PlanetScale does not allow foreign keys in the database schema (`ERROR 70100 (1317): foreign key constraints are not allowed, see https://code.openark.org/blog/mysql/the-problem-with-mysql-foreign-key-constraints-in-online-schema-changes`), which Prisma relies on for relations. - Starting with 2.27.0 Prism
Error Output
ERROR 70100 (1317): foreign key constraints are not allowed, see https://code.openark.org/blog/mysql/the-problem-with-mysql-foreign-key-constraints-in-online-schema-changes`), which Prisma relies on for rel
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Using Prisma with a PlanetScale database
This is finally available ๐ https://twitter.com/planetscaledata/status/1427371097352069120
Trust Score
6 verifications
- 1
https://twitter.com/planetscaledata/status/1427371097352069120
https://twitter.com/planetscaledata/status/1427371097352069120
Validation
Resolved in prisma/prisma GitHub issue #7292. Community reactions: 20 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep