npm i -D prisma

npm i @prisma/client
npx prisma init

Database url을 넣자! ⇒ planet scale


prisma db 설정

import { PrismaClient } from '@prisma/client';

// global This에 선언 해준다.
declare global {
  var prisma: PrismaClient | undefined;
}

const prismadb = globalThis.prisma || new PrismaClient();
if (process.env.NODE_ENV !== 'production') globalThis.prisma = prismadb;

export default prismadb;

planet Scale 설정!

DATABASE_URL='mysql://jxr1mi7l3yqhm0u1gnt7:pscale_pw_PrfcRGNAaW5Y41Uphk2UuGpKRa4GmxGLoQsA5sYjiHo@aws.connect.psdb.cloud/kyummerce-admin?sslaccept=strict'
// This is your Prisma schema file,
// learn more about it in the docs: <https://pris.ly/d/prisma-schema>

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
  relationMode = "prisma"
}