difflore_core/migration.rs
1//! Retired local persistence migrations.
2//!
3//! Current installs create per-project context indexes directly at
4//! `~/.difflore/projects/{project_hash}/context-index.db`. The former
5//! global `~/.difflore/context-index.db` split migration is intentionally
6//! retired: new runtimes must not copy or reinterpret historical index
7//! contents.
8
9use crate::context::index_db;
10use crate::errors::CoreError;
11
12/// Startup guard for retired local index layouts.
13///
14/// If a retired global `context-index.db` is present, fail closed and leave
15/// it untouched. Users can delete/move the file and let the current
16/// per-project index rebuild from canonical rules.
17pub async fn run_if_needed() -> Result<(), CoreError> {
18 let retired_global_index = index_db::retired_global_index_db_path()?;
19 if retired_global_index.exists() {
20 return Err(CoreError::Internal(format!(
21 "retired context-index split migration refused retired global index at {}; \
22 move or delete that file, then let per-project indexes rebuild",
23 retired_global_index.display()
24 )));
25 }
26
27 Ok(())
28}