ForeignKey class
Represents a foreign key constraint in MySQL.
Foreign keys establish and enforce a link between data in two tables, ensuring referential integrity in the database.
Example:
final fk = ForeignKey(
name: 'user_id',
refTable: 'users',
refColumn: 'id',
onDelete: 'CASCADE',
onUpdate: 'RESTRICT',
);
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String
-
The name of the foreign key field in the current table
getter/setter pair
- onDelete ↔ String
-
Action to take when the referenced record is deleted (default: 'NO ACTION')
getter/setter pair
- onUpdate ↔ String
-
Action to take when the referenced record is updated (default: 'NO ACTION')
getter/setter pair
- refColumn ↔ String
-
The name of the referenced column in the target table (default: 'id')
getter/setter pair
- refTable ↔ String
-
The name of the referenced table
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toSQL(
) → String -
Generates the SQL foreign key constraint definition.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited