drop method Null safety

Future<void> drop(
  1. DatabaseSchemaEntity entity
)

Drops a table, trigger or index.

Implementation

Future<void> drop(DatabaseSchemaEntity entity) async {
  final context = _createContext();
  final escapedName = context.identifier(entity.entityName);

  String kind;

  if (entity is TableInfo) {
    kind = 'TABLE';
  } else if (entity is Trigger) {
    kind = 'TRIGGER';
  } else if (entity is Index) {
    kind = 'INDEX';
  } else if (entity is ViewInfo) {
    kind = 'VIEW';
  } else {
    // Entity that can't be dropped.
    return;
  }

  await _issueCustomQuery('DROP $kind IF EXISTS $escapedName;');
}