ForeignKeyConstraint class

Foreign key constraint annotation for defining foreign key constraints

The column and referenced table/column must exist.

Example:

@ForeignKeyConstraint(
  column: 'user_id',
  referencedTable: 'users',
  referencedColumn: 'id',
  onDelete: ConstraintAction.cascade,
)
int? userId;

Constructors

ForeignKeyConstraint({String? column, required String referencedTable, String referencedColumn = 'id', ConstraintAction onDelete = ConstraintAction.noAction, ConstraintAction onUpdate = ConstraintAction.noAction, String? name})
const

Properties

column → String?
Column name in this table (defaults to field name if on a field)
final
hashCode → int
The hash code for this object.
no setterinherited
name → String?
Optional constraint name
final
onDelete → ConstraintAction
Action on delete of referenced row
final
onUpdate → ConstraintAction
Action on update of referenced row
final
referencedColumn → String
Referenced column name (usually 'id')
final
referencedTable → String
Referenced table name
final
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
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited