Sometimes you want to add constraints on a table level, rather than a column level. The following methods will let you accomplish that.
Create a generic index from one or more columns.
Example:
SchemaBuilder
SQL (MySQL)
Create a foreign key constraint from one or more columns. Follow up this call with calls to the TableIndex
's references
and onTable
methods.
Example:
SchemaBuilder
SQL (MySQL)
Create a primary key constraint from one or more columns.
Example:
SchemaBuilder
SQL (MySQL)
Create a unique constraint from one or more columns.
Example:
SchemaBuilder
SQL (MySQL)
Argument
Type
Required
Default
Description
columns
string or array
true
The column or array of columns that make up the index.
name
string
false
A generated name consisting of the table name and column name(s).
The name of the index constraint.
Argument
Type
Required
Default
Description
columns
string or array
true
The column or array of columns that references a key or keys on another table.
name
string
false
A generated name consisting of the table name and column name(s).
The name of the foreign key constraint.
Argument
Type
Required
Default
Description
columns
string or array
true
The column or array of columns that make up the primary key.
name
string
false
A generated name consisting of the table name and column name(s).
The name of the primary key constraint.
Argument
Type
Required
Default
Description
columns
string or array
true
The column or array of columns that make up the unique constraint.
name
string
false
A generated name consisting of the table name and column name(s).
The name of the unique constraint.