addColumnForeignKeyConstraint method

void addColumnForeignKeyConstraint(
  1. ColumnForeignKeyConstraint constraint
)

Implementation

void addColumnForeignKeyConstraint(ColumnForeignKeyConstraint constraint) {
  statement.buffer.write(
    'REFERENCES ${constraint.otherTableName} (${constraint.otherColumnName})',
  );
  if (constraint.onUpdate case final onUpdate?) {
    statement.buffer.write(' ON UPDATE ${onUpdate.defaultLexeme}');
  }
  if (constraint.onDelete case final onDelete?) {
    statement.buffer.write(' ON UPDATE ${onDelete.defaultLexeme}');
  }

  if (constraint.initiallyDeferred) {
    statement.buffer.write('DEFERRABLE INITIALLY DEFERRED');
  }
}