Connecting a PlanetScale DB with Prisma
Set up the schema.prisma file as below.
text
generator client {
provider = "prisma-client-js"
// previewFeatures = ["referentialIntegrity"] //PlanetScale doesn't support foreign keys the way MySQL does, so this line should be added, but the current version seems to support it automatically
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma" // Relations are checked through Prisma.
}
model User {
id Int @id @default(autoincrement())
phone Int? @unique
email String? @unique
name String
avatar String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}Then, assuming you're logged in and connected, enter the command below in the terminal!
bash
npx prisma db pushYou can see the push went through as below.

- #db
- #Nomad Coders
- #PlanetScale
- #Prisma