Prisma schema field types
Every field in a Prisma model has a type: a built-in scalar, an enum, another
model (a relation), or a composite type. Each scalar maps to a default database
column that you can override with a @db native-type modifier. This searchable
reference lists the scalar types, relation forms and native modifiers with their
default PostgreSQL mapping so you can model schemas precisely.
How it works
A field is name Type modifiers attributes. Optionality and lists are encoded
with ? and [], and native database types are set with @db:
model User {
id Int @id @default(autoincrement())
email String @unique @db.VarChar(320)
balance Decimal @db.Decimal(12, 2)
createdAt DateTime @default(now()) @db.Timestamptz(3)
metadata Json?
posts Post[]
}
The Prisma scalar (String, Decimal, DateTime) chooses the default column,
and the @db attribute pins the exact native type. Relations link models by
referencing the related model type plus a @relation mapping.
Tips and notes
- Use
Decimal(neverFloat) for money to avoid floating-point rounding. DateTimedefaults totimestamp(3); use@db.Timestamptzto store the zone.Jsonis great for flexible blobs but cannot be deeply queried portably.- Append
?for nullable and[]for list;BigIntmaps to 64-bit integers.