renameTable method Null safety

Future<void> renameTable(
  1. TableInfo<Table, dynamic> table,
  2. String oldName
)

Changes the table name from oldName to the current TableInfo.actualTableName.

After renaming a table in drift or Dart and re-running the generator, you can use renameTable in a migration step to rename the table in existing databases.

Implementation

Future<void> renameTable(TableInfo table, String oldName) async {
  final context = _createContext();
  context.buffer.write('ALTER TABLE ${context.identifier(oldName)} '
      'RENAME TO ${context.identifier(table.actualTableName)};');
  return _issueCustomQuery(context.sql);
}