79834309

Date: 2025-12-01 02:44:45
Score: 0.5
Natty:
Report link

U need to add output and define schemas ini datasource.

generator client {
  provider = "prisma-client-js"
  output   = "../generated/prisma/client"
}

datasource db {
  provider = "postgresql"
  schemas = ["your-schemas"]
}

Then u need add @schema("") in your model. Example :

model sku {
  a       Int      @id @default(autoincrement())
  b       String   @unique @map("b") @db.VarChar(255)
  c       Int?     @map("c")
  createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
  updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamp(6)


  @@index([b])
  @@map("c")
  @@schema("your-schemas")
}

u can make it global using :

import { PrismaClient } from '../generated/prisma/client/index.js';
import { PrismaPg } from '@prisma/adapter-pg';

const globalForPrisma = globalThis;

// adapter Postgres (Prisma Data Proxy / Accelerate style)
const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL
});

export const prisma =
  globalForPrisma.prisma ??
  new PrismaClient({
    adapter
  });

// simpan instance ke global supaya tidak recreate saat hot reload / nodemon
if (process.env.NODE_ENV !== 'production') {
  globalForPrisma.prisma = prisma;
}
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @schema
  • Low reputation (1):
Posted by: 08. Flexsy Bilbis Triwibowo