Numeric Types
int()
MySQLINT type for 32-bit integers.
boolean
default:"false"
Whether the column is unsigned.
Examples
bigint()
MySQLBIGINT type for 64-bit integers. Supports both number and bigint modes.
'number' | 'bigint'
required
'number': Values up to 2^53-1 as JavaScript numbers'bigint': Full 64-bit range as JavaScript bigint
boolean
default:"false"
Whether the column is unsigned.
Examples
tinyint()
MySQLTINYINT type for small integers (-128 to 127 or 0 to 255 unsigned).
Examples
smallint()
MySQLSMALLINT type for small integers (-32768 to 32767 or 0 to 65535 unsigned).
Examples
mediumint()
MySQLMEDIUMINT type for medium-sized integers.
Examples
serial()
MySQLSERIAL type, which is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
serial() automatically applies .notNull(), .autoincrement(), and .primaryKey() modifiers.Examples
decimal()
MySQLDECIMAL type for exact numeric values. Supports string, number, and bigint modes.
'string' | 'number' | 'bigint'
default:"'string'"
How to represent the value in JavaScript.
number
Total number of digits.
number
Number of digits after decimal point.
boolean
default:"false"
Whether the column is unsigned.
Examples
float()
MySQLFLOAT type for single-precision floating-point numbers.
Examples
double()
MySQLDOUBLE type for double-precision floating-point numbers.
Examples
real()
MySQLREAL type, synonym for DOUBLE.
String Types
varchar()
MySQLVARCHAR type for variable-length strings.
number
required
Maximum length of the string (1 to 65,535).
string[]
Array of allowed values for type safety.
Examples
char()
MySQLCHAR type for fixed-length strings.
number
Fixed length of the string (0 to 255). Defaults to 1.
Examples
text()
MySQLTEXT type for long text content (up to 65,535 characters).
Examples
tinytext()
MySQLTINYTEXT type for short text (up to 255 characters).
mediumtext()
MySQLMEDIUMTEXT type for medium-length text (up to 16,777,215 characters).
Examples
longtext()
MySQLLONGTEXT type for very long text (up to 4,294,967,295 characters).
Examples
Binary Types
binary()
MySQLBINARY type for fixed-length binary data.
Examples
varbinary()
MySQLVARBINARY type for variable-length binary data.
Examples
Date and Time Types
date()
MySQLDATE type for dates without time.
'date' | 'string'
default:"'date'"
'date': JavaScript Date object'string': ISO date string (YYYY-MM-DD)
Examples
datetime()
MySQLDATETIME type for date and time.
'date' | 'string'
default:"'date'"
How to represent the value in JavaScript.
0 | 1 | 2 | 3 | 4 | 5 | 6
Fractional seconds precision (0-6 digits).
Examples
timestamp()
MySQLTIMESTAMP type for Unix timestamps.
'date' | 'string'
default:"'date'"
How to represent the value in JavaScript.
0 | 1 | 2 | 3 | 4 | 5 | 6
Fractional seconds precision.
TIMESTAMP has a range from ‘1970-01-01 00:00:01’ UTC to ‘2038-01-19 03:14:07’ UTC.Examples
time()
MySQLTIME type for time of day.
Examples
year()
MySQLYEAR type for year values.
Examples
Boolean Type
boolean()
MySQLBOOLEAN type (alias for TINYINT(1)).
Examples
JSON Type
json()
MySQLJSON type for storing JSON data.
The JSON column automatically serializes/deserializes JavaScript objects.
Examples
Enum Type
mysqlEnum()
MySQLENUM type for predefined string values.
string[]
required
Array of allowed enum values (at least one value required).
Examples
Custom Types
customType()
Define custom column types with custom serialization/deserialization logic.function
required
Function that returns the MySQL column type as a string.
function
Transform value before sending to database.
function
Transform value after reading from database.