Column Constraints
Last updated
Last updated
A TableIndex
can be created directly from a Blueprint
or from a existing Column
. The TableIndex
includes methods for further configuring the index which is required when defining foreign keys.
Set the referencing column for a foreign key relationship. For example, id
for a country_id
column.
Example:
SchemaBuilder
SQL (MySQL)
Sets the referencing table for a foreign key relationship. For example, countries
for a country_id
column.
Example:
SchemaBuilder
SQL (MySQL)
Set the strategy for updating foreign keys when the parent key is updated.
Example:
SchemaBuilder
SQL (MySQL)
Set the strategy for updating foreign keys when the parent key is deleted.
Example:
SchemaBuilder
SQL (MySQL)
Argument
Type
Required
Default
Description
columns
any
true
A column or array of columns that represents the foreign key reference.
Argument
Type
Required
Default
Description
table
string
true
The referencing table name.
Argument
Type
Required
Default
Description
option
string
true
The strategy to use. Available values are: RESTRICT, CASCADE, SET NULL, NO ACTION, SET DEFAULT
Argument
Type
Required
Default
Description
option
string
true
The strategy to use. Available values are: RESTRICT, CASCADE, SET NULL, NO ACTION, SET DEFAULT