Skip to content

Low-Level Types

Low-level types give you direct control over SQL column types when semantic types don’t fit your needs.

TypeSQLNotes
col.string(n)VARCHAR(n)Fixed-length string
col.text()TEXTUnlimited length
col.integer()INTEGER32-bit integer
col.float()FLOATFloating point
col.decimal(p,s)NUMERIC(p, s)Precise decimal
col.boolean()BOOLEANTrue/false
col.date()DATEDate only
col.time()TIMETime only
col.datetime()TIMESTAMPDate and time
col.uuid()UUIDUnique identifier
col.json()JSONBJSON data
col.base64()BYTEA/BLOBBase64 encoded
col.enum([...])CHECKConstrained values
export default table({
...
// Strings
sku: col.string(50).unique(), // VARCHAR(50)
description: col.text().optional(), // TEXT, nullable
// Numbers
amount: col.decimal(10, 2), // DECIMAL(10,2)
count: col.integer(), // INTEGER
rate: col.float(), // FLOAT
// Dates and Times
event_date: col.date(), // DATE
start_time: col.time(), // TIME
created_at: col.datetime(), // TIMESTAMP
// JSON and UUID
id: col.uuid(), // UUID (use col.id() for primary key)
preferences: col.json(), // JSONB
// Enums
priority: col.enum(["low", "normal", "high"]).default("normal"),
});

For most cases, use semantic types instead - they include patterns and sensible defaults:

Instead of…Use…
col.string(255)col.email()
col.string(100)col.name()
col.integer()col.quantity()
col.decimal(19,4)col.money()
col.boolean()col.flag()