Database
Update schema
Edit Prisma schema, create migrations, push, and generate the client.
The database schema is defined in packages/database/prisma/schema.prisma. See the Prisma schema docs for full syntax.
Add or change a model
Example: a Post model related to User:
model Post {
id String @id @default(cuid())
title String
content String
author User @relation(fields: [authorId], references: [id])
authorId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("post")
}Also add the reverse relation on User (posts Post[]) when you introduce the model.
For a full product slice (schema → API → UI), see Build a feature.
Migrate (recommended)
Create and apply a migration using the direct connection (DIRECT_URL):
pnpm --filter @repo/database db:migrate
# or from the monorepo root:
pnpm prisma:migrateThe script runs prisma migrate dev with DATABASE_URL temporarily set to DIRECT_URL.
For CI and production deploys:
pnpm --filter @repo/database db:migrate:deployPush without a migration file
To sync the schema quickly in development without writing a migration:
pnpm --filter @repo/database db:pushThis uses DATABASE_URL as-is (pooled URL is fine for local Docker).
Generate Prisma Client
After schema changes, regenerate the client:
pnpm --filter @repo/database db:generate