Skip to content

Rename graph.db → cora.db with auto-migrate #395

Description

@ajianaz

Problem

Current database file ~/.codecora/cora-code/graph.db only reflects the v1 purpose (symbol graph). After v5 migration adds reviews/findings/finding_events, the name is misleading.

Solution

Rename to cora.db as the single source of truth for all cora-code data.

Changes

  1. src/data_dir.rs: Change graph_db_path()cora_db_path(), rename file from graph.db to cora.db
  2. Auto-migrate logic: On startup, if cora.db does not exist but graph.db does, rename it automatically:

n pub fn cora_db_path() -> PathBuf {
let new_path = cora_data_dir().join("cora.db");
let old_path = cora_data_dir().join("graph.db");
if !new_path.exists() && old_path.exists() {
if let Err(e) = std::fs::rename(&old_path, &new_path) {
eprintln!("Warning: failed to migrate graph.db → cora.db: {e}");
return old_path;
}
}
new_path
}

3. **Update all references**:
- `src/data_dir.rs` — function name + test assertion
- `src/index/mod.rs:29` — doc comment
- `src/index/schema.rs:131` — doc comment
4. **Update docs** (non-breaking, can be separate PR):
- `docs/standards/codecora-data-directory.md`
- `docs/code-intelligence.md`
- `docs/roadmap.md`

### Surface Area

| File | Type | Lines Changed |
|------|------|--------------|
| `src/data_dir.rs` | Code | ~15 |
| `src/index/mod.rs` | Doc comment | 1 |
| `src/index/schema.rs` | Doc comment | 1 |
| `CHANGELOG.md` | Historical — do not edit | — |

### Testing

- [ ] Unit test: `cora_db_path()` returns path ending in `cora.db`
- [ ] Integration test: if `graph.db` exists and `cora.db` does not, auto-rename happens
- [ ] Integration test: if both exist, `cora.db` takes precedence
- [ ] Existing tests pass (update assertion strings)

### Acceptance Criteria

- `cora index`, `cora review`, `cora scan` all use `cora.db`
- Existing `graph.db` auto-migrated on first run
- No data loss during migration

---
Ref: #356, #357, #358, #359 (v0.9.0 milestone)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions