deleteColumn method Null safety

void deleteColumn(
  1. String tableName,
  2. String columnName
)

Validates and deletes a column in a table in schema.

Implementation

void deleteColumn(String tableName, String columnName) {
  final table = schema!.tableForName(tableName);
  if (table == null) {
    throw SchemaException("Table $tableName does not exist.");
  }

  final column = table.columnForName(columnName);
  if (column == null) {
    throw SchemaException("Column $columnName does not exists.");
  }

  table.removeColumn(column);

  if (store != null) {
    commands.addAll(store!.deleteColumn(table, column));
  } else {
    commands.add('database.deleteColumn("$tableName", "$columnName");');
  }
}