addColumn method Null safety

void addColumn(
  1. String tableName,
  2. SchemaColumn column,
  3. {String? unencodedInitialValue}
)

Validates and adds a column to a table in schema.

Implementation

void addColumn(
  String tableName,
  SchemaColumn column, {
  String? unencodedInitialValue,
}) {
  final table = schema!.tableForName(tableName);
  if (table == null) {
    throw SchemaException("Table $tableName does not exist.");
  }

  table.addColumn(column);
  if (store != null) {
    commands.addAll(
      store!.addColumn(
        table,
        column,
        unencodedInitialValue: unencodedInitialValue,
      ),
    );
  } else {
    commands.add(
      'database.addColumn("${column.table!.name}", ${_getNewColumnExpression(column)});',
    );
  }
}