clearAllData method
Clear all data (database and index files) and reset the engine.
This is a destructive operation that:
- Closes the database connection and the vector store
- Deletes the SQLite database file and its sidecars
- Deletes the vector store and the HNSW indexes of every collection
- Re-initializes the database and service
It first waits for running work in every collection (ingests, removals, rebuilds, warmups). Writes and rebuilds called while it runs start after the new database is ready.
Implementation
Future<void> clearAllData() async {
if (_disposed) {
throw StateError('RagEngine was disposed. Initialize a new engine.');
}
final running = _resetInProgress;
if (running != null) return running.future;
final reset = Completer<void>();
_resetInProgress = reset;
try {
await _clearAllData();
} finally {
_resetInProgress = null;
reset.complete();
}
}