Column Modifiers
Last updated
Last updated
When creating a column from the Blueprint
object, a Column
object is returned. This column
gives you access to a few modifier commands to further configure the column.
Attach a comment to the column.
Example:
SchemaBuilder
SQL (MySQL)
Sets a default value for the column.
Note: The value is not escaped, allowing you to specify functions like NOW()
or literals like 1
. To specify a literal string, wrap the value in quotes.
Example:
SchemaBuilder
SQL (MySQL)
Sets the column to allow null values.
All columns are created as NOT NULL
by default. As such, there is no notNull
method.
Example:
SchemaBuilder
SQL (MySQL)
Adds the column as a primary key for the table.
The primaryKey
method returns a TableIndex
instance. Additional methods can be chained off of it.
Example:
SchemaBuilder
SQL (MySQL)
Creates a foreign key constraint for the column.
IMPORTANT: Additional configuration of the foreign constraint is done by calling methods on the returned TableIndex
instance.
Example:
SchemaBuilder
SQL (MySQL)
Sets the column as unsigned.
Example:
SchemaBuilder
SQL (MySQL)
Sets the column to have the UNIQUE constraint.
Example:
SchemaBuilder
SQL (MySQL)
Sets the column to have the a default value of CURRENT_TIMESTAMP
.
Example:
SchemaBuilder
SQL (Postgres)
Argument
Type
Required
Default
Description
comment
string
true
The comment text.
Argument
Type
Required
Default
Description
value
string
true
The default value.
Argument
Type
Required
Default
Description
No arguments
Argument
Type
Required
Default
Description
indexName
string
false
A derived name built from the table name and column name.
The name to use for the primary key constraint.
Argument
Type
Required
Default
Description
value
string
true
The default value.
Argument
Type
Required
Default
Description
No arguments
Argument
Type
Required
Default
Description
No arguments
Argument
Type
Required
Default
Description
No arguments