addColumn method

void addColumn(
  1. ColumnDef col
)

Add a new column with the given default for existing rows.

Implementation

void addColumn(ColumnDef col) {
  if (columns.any((c) => c.name.toLowerCase() == col.name.toLowerCase())) {
    throw StateError('Column ${col.name} already exists');
  }
  final fill =
      col.defaultValue == null ? null : coerce(col.defaultValue, col.type);
  columns.add(col);
  for (final r in rows) {
    r.add(fill);
  }
  invalidateKeyCache();
  invalidateUniqueCaches();
}