All pages
Powered by GitBook
1 of 1

Column Modifiers

comment

Attach a comment to the column.

Example:

SchemaBuilder

SQL (MySQL)

default

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)

nullable

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)

primaryKey

Adds the column as a primary key for the table.

Example:

SchemaBuilder

SQL (MySQL)

references

Creates a foreign key constraint for the column.

Example:

SchemaBuilder

SQL (MySQL)

unsigned

Sets the column as unsigned.

Example:

SchemaBuilder

SQL (MySQL)

unique

Sets the column to have the UNIQUE constraint.

Example:

SchemaBuilder

SQL (MySQL)

withCurrent

Sets the column to have the a default value of CURRENT_TIMESTAMP.

Example:

SchemaBuilder

SQL (Postgres)

storedAs

Creates a stored computed column. Computed columns are defined as expressions between other columns and/or constant values. Stored computed columns are saved in the database to avoid computing on every query.

Your database grammar may not differentiate between stored computed columns and virtual computed columns. Research your grammar's implementation for more details.

virtualAs

Creates a virtual computed column. Computed columns are defined as expressions between other columns and/or constant values. Virtual computed columns are computed on every query.

Your database grammar may not differentiate between stored computed columns and virtual computed columns. Research your grammar's implementation for more details.