Reference

Column Types

Every column type available in the TypeScript DSL and its SQL equivalent.

Any column can be made nullable by chaining .optional(). For binary data like images and file uploads, use the Files & Blobs pattern rather than s.bytes() directly.

There are a number of column types available which cover most common use cases:

DSLTypeScript typeSQL type
s.string()stringTEXT
s.boolean()booleanBOOLEAN
s.int()numberINTEGER
s.float()numberREAL
s.timestamp()Date | numberTIMESTAMP
s.bytes()Uint8ArrayBYTEA
s.ref("table")string (row ID)UUID (FK)
s.array(s.string())string[]TEXT[]
s.enum("a", "b")"a" | "b"ENUM('a','b')
s.json()JsonValueJSON
s.json(schema)inferred from schemaJSON

Any column can be made nullable with .optional().

JSON columns are atomic. The entire value is replaced on every write. Use s.json() for untyped JSON, or s.json(schema) with a Zod-compatible schema for typed validation. For structured data that needs per-field updates, use separate columns or a related table instead.

Ref naming convention: s.ref() columns must have a name ending in Id or _id. For s.array(s.ref()), the name must end in Ids or _ids. The runtime will throw if a ref column does not follow this convention.