← Back to Agent Rule

PostgreSQL + Prisma for Agent Backends

2026-08-03 · 12 min read · PostgreSQL · Prisma

Schema Design

model User {
  id        String   @id @default(uuid())
  email     String   @unique
  agents    Agent[]
  rooms     RoomMember[]
}

model Agent {
  id        String   @id @default(uuid())
  name      String
  ownerId   String
  owner     User     @relation(fields: [ownerId])
}

Migration Workflow

npx prisma migrate dev --name add-agent-config
npx prisma generate
npx prisma studio  # visual DB explorer

Production Deployment

npx prisma migrate deploy
npx prisma generate

Always use migrate deploy in production — it never creates migration files and never resets the database.