hasIndex method

  1. @override
Future<bool> hasIndex(
  1. String table,
  2. String index, {
  3. String? schema,
  4. String? type,
})
override

Determines if the given table has a specific index. Optionally check by index type ('primary', 'unique', or specific driver type).

Implementation

@override
Future<bool> hasIndex(
  String table,
  String index, {
  String? schema,
  String? type,
}) async {
  return snapshot.indexes.any((idx) {
    final typeMatches =
        type == null ||
        (type == 'primary' && idx.primary) ||
        (type == 'unique' && idx.unique) ||
        _equals(type, idx.type);

    return _equalsOwner(idx.schema, schema) &&
        _equals(idx.tableName, table) &&
        _equals(idx.name, index) &&
        typeMatches;
  });
}