foreignId method

ColumnBuilder foreignId(
  1. String name, {
  2. ColumnMutation mutation = ColumnMutation.add,
  3. bool unsigned = true,
  4. String? constrainedTable,
  5. String referencedColumn = 'id',
  6. ReferenceAction onDelete = ReferenceAction.noAction,
  7. ReferenceAction onUpdate = ReferenceAction.noAction,
})

Implementation

ColumnBuilder foreignId(
  String name, {
  ColumnMutation mutation = ColumnMutation.add,
  bool unsigned = true,
  String? constrainedTable,
  String referencedColumn = 'id',
  ReferenceAction onDelete = ReferenceAction.noAction,
  ReferenceAction onUpdate = ReferenceAction.noAction,
}) {
  final builder = bigInteger(name, mutation: mutation, unsigned: unsigned);
  if (constrainedTable != null) {
    foreign(
      [name],
      references: constrainedTable,
      referencedColumns: [referencedColumn],
      onDelete: onDelete,
      onUpdate: onUpdate,
    );
  }
  return builder;
}