Numeric Types
integer()
PostgreSQLINTEGER type for whole numbers.
number
SQL type: INTEGER
serial()
Auto-incrementing integer column.number
SQL type: SERIAL (equivalent to INTEGER with DEFAULT nextval('sequence'))
Note: Automatically has .notNull() and .default() applied.
bigint()
PostgreSQLBIGINT type for large integers.
'number' | 'bigint'
required
'number': Use JavaScriptnumber(safe up to 2^53)'bigint': Use JavaScriptbigintfor larger values
number or bigint (based on mode)
SQL type: BIGINT
bigserial()
Auto-incrementing bigint column.'number' | 'bigint'
required
Determines whether to use JavaScript
number or bigintBIGSERIAL
smallint()
PostgreSQLSMALLINT type for small integers (-32,768 to 32,767).
number
SQL type: SMALLINT
smallserial()
Auto-incrementing smallint column.SMALLSERIAL
numeric()
PostgreSQLNUMERIC/DECIMAL type for exact decimal values.
number
Total number of digits
number
Number of digits after decimal point
'string' | 'number' | 'bigint'
'string'(default): Returns string for exact precision'number': Converts to JavaScript number'bigint': Converts to JavaScript bigint
string, number, or bigint (based on mode)
SQL type: NUMERIC(precision, scale)
Alias: decimal() - same as numeric()
real()
PostgreSQLREAL type for floating-point numbers (single precision).
number
SQL type: REAL
doublePrecision()
PostgreSQLDOUBLE PRECISION type for floating-point numbers.
number
SQL type: DOUBLE PRECISION
String Types
varchar()
PostgreSQLVARCHAR type for variable-length strings.
number
Maximum string length. If omitted, creates
VARCHAR without length limit.readonly string[]
TypeScript enum values for type safety
string
SQL type: VARCHAR or VARCHAR(length)
char()
PostgreSQLCHAR type for fixed-length strings.
number
Fixed string length
string
SQL type: CHAR(length)
text()
PostgreSQLTEXT type for unlimited-length strings.
readonly string[]
TypeScript enum values for type safety
string
SQL type: TEXT
Date and Time Types
timestamp()
PostgreSQLTIMESTAMP type for date and time.
'date' | 'string'
'date'(default): Use JavaScriptDateobjects'string': Keep as ISO 8601 string
boolean
If
true, creates TIMESTAMP WITH TIME ZONE. Default: false0 | 1 | 2 | 3 | 4 | 5 | 6
Fractional seconds precision (0-6 digits)
Date or string (based on mode)
SQL type: TIMESTAMP or TIMESTAMP WITH TIME ZONE
date()
PostgreSQLDATE type for dates without time.
'date' | 'string'
'string'(default): ISO date string format'date': JavaScript Date object
string or Date (based on mode)
SQL type: DATE
time()
PostgreSQLTIME type for time without date.
boolean
If
true, creates TIME WITH TIME ZONE0 | 1 | 2 | 3 | 4 | 5 | 6
Fractional seconds precision
string
SQL type: TIME or TIME WITH TIME ZONE
interval()
PostgreSQLINTERVAL type for time intervals.
string
Interval fields specification (e.g., ‘day’, ‘hour to second’)
0 | 1 | 2 | 3 | 4 | 5 | 6
Fractional seconds precision
string
SQL type: INTERVAL
Boolean Type
boolean()
PostgreSQLBOOLEAN type.
boolean
SQL type: BOOLEAN
JSON Types
json()
PostgreSQLJSON type for JSON data.
unknown (use generic type parameter for type safety)
SQL type: JSON
jsonb()
PostgreSQLJSONB type for binary JSON (more efficient, supports indexing).
unknown (use generic type parameter for type safety)
SQL type: JSONB
Note: JSONB is generally preferred over JSON for better performance and indexing support.
UUID Type
uuid()
PostgreSQLUUID type.
string
SQL type: UUID
Methods:
.defaultRandom(): Sets default togen_random_uuid()
Network Types
inet()
PostgreSQLINET type for IPv4 or IPv6 addresses.
string
SQL type: INET
cidr()
PostgreSQLCIDR type for network addresses.
string
SQL type: CIDR
macaddr()
PostgreSQLMACADDR type for MAC addresses.
string
SQL type: MACADDR
macaddr8()
PostgreSQLMACADDR8 type for MAC addresses (EUI-64 format).
string
SQL type: MACADDR8
Geometric Types
point()
PostgreSQLPOINT type for geometric points.
POINT
line()
PostgreSQLLINE type.
LINE
Enum Types
pgEnum()
Defines a PostgreSQL enum type.string
required
Enum type name in database
readonly string[]
required
Array of possible values
ENUM type
Custom Types
customType()
Defines a custom column type with custom serialization.Column Modifiers
All column types support these modifiers:.notNull()
Marks column asNOT NULL.