renameTable method Null safety

void renameTable(
  1. String currentTableName,
  2. String newName
)

Validates and renames a table in schema.

Implementation

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

  schema!.renameTable(table, newName);
  if (store != null) {
    commands.addAll(store!.renameTable(table, newName));
  } else {
    commands.add("database.renameTable('$currentTableName', '$newName');");
  }
}