cocomon

Schema

The schema.prisma mental model and the main constructs you will use every day.

Schema

The schema is the contract for the whole system. It drives code generation, runtime metadata, validation, and migration planning.

Supported top-level blocks

  • datasource
  • generator
  • model
  • enum

Minimal example:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "comon_orm"
  output   = "lib/generated/comon_orm_client.dart"
}

enum Role {
  admin
  member
}

model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  role  Role
}

What lives in schema and what does not

Use the schema for:

  • data model structure
  • keys, unique constraints, and indexes
  • relation ownership and referential actions
  • enum definitions
  • logical-to-physical name mapping through @map and @@map
  • generator configuration such as output path and SQLite helper flavor

Do not expect the schema alone to replace rollout decisions. A destructive schema diff still needs human review at migration time.

On this page