A signed integer, stored in 0, 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
tinyint
smallint
mediumint
bigint
We’ve omitted config of M in bigint(M), since it indicates the display width of the numeric type
---
real
decimal
double
float
---
serial
SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
---
binary
varbinary
---
char
varchar
You can define { enum: ["value1", "value2"] } config to infer insert and select types, it won’t check runtime values.
text
You can define { enum: ["value1", "value2"] } config to infer insert and select types, it won’t check runtime values.
---
boolean
---
date
datetime
time
year
timestamp
---
json
You can specify .$type<..>() for json object inference, it won’t check runtime values.
It provides compile time protection for default values, insert and select schemas.
---
enum
---
Customizing data type
Every column builder has a .$type() method, which allows you to customize the data type of the column. This is useful, for example, with unknown or branded types.
Not null
NOT NULL constraint dictates that the associated column may not contain a NULL value.
Default value
The DEFAULT clause specifies a default value to use for the column if no value
is explicitly provided by the user when doing an INSERT.
If there is no explicit DEFAULT clause attached to a column definition,
then the default value of the column is NULL.
An explicit DEFAULT clause may specify that the default value is NULL,
a string constant, a blob constant, a signed-number, or any constant expression enclosed in parentheses.
When using $default() or $defaultFn(), which are simply different aliases for the same function,
you can generate defaults at runtime and use these values in all insert queries.
These functions can assist you in utilizing various implementations such as uuid, cuid, cuid2, and many more.
Note: This value does not affect the drizzle-kit behavior, it is only used at runtime in drizzle-orm
When using $onUpdate() or $onUpdateFn(), which are simply different aliases for the same function,
you can generate defaults at runtime and use these values in all update queries.
Adds a dynamic update value to the column. The function will be called when the row is updated,
and the returned value will be used as the column value if none is provided.
If no default (or $defaultFn) value is provided, the function will be called
when the row is inserted as well, and the returned value will be used as the column value.
Note: This value does not affect the drizzle-kit behavior, it is only used at runtime in drizzle-orm