dropIndex method

Future<bool> dropIndex(
  1. String name
)

Drop secondary index name. Removes the on-disk files and rewrites meta.json. Idempotent — returns false if the index didn't exist.

Implementation

Future<bool> dropIndex(String name) async {
  final si = _secondary.remove(name);
  if (si == null) return false;
  await si.file.close();
  // Persist schema first so a crash mid-delete still removes the
  // index from the next opener's view.
  await _writeMeta(basePath, columns, primaryKeyIndex, _indexDescriptors(),
      pageSize: _heapFile.pageSize);
  for (final ext in const ['', '.journal']) {
    final f = File('$basePath.idx_$name$ext');
    if (await f.exists()) {
      try {
        await f.delete();
      } catch (_) {/* best-effort */}
    }
  }
  return true;
}