replaceColumn method Null safety

void replaceColumn(
  1. SchemaColumn existingColumn,
  2. SchemaColumn newColumn
)

Replaces existingColumn with newColumn in this table.

Implementation

void replaceColumn(SchemaColumn existingColumn, SchemaColumn newColumn) {
  if (!columns.contains(existingColumn)) {
    throw SchemaException(
      "Column ${existingColumn.name} does not exist on $name.",
    );
  }

  final index = _columnStorage!.indexOf(existingColumn);
  _columnStorage![index] = newColumn;
  newColumn.table = this;
  existingColumn.table = null;
}