hasIndex method
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 {
final indexes = await listIndexes(table, schema: schema);
for (final idx in indexes) {
final typeMatches =
type == null ||
(type == 'primary' && idx.primary) ||
(type == 'unique' && idx.unique) ||
type.toLowerCase() == idx.type?.toLowerCase();
if (idx.name.toLowerCase() == index.toLowerCase() && typeMatches) {
return true;
}
}
return false;
}