Skip to content

feat: migrate index DB to global ~/.codecora/cora-code/graph.db#355

Merged
ajianaz merged 2 commits into
developfrom
feat/global-index-db
Jul 22, 2026
Merged

feat: migrate index DB to global ~/.codecora/cora-code/graph.db#355
ajianaz merged 2 commits into
developfrom
feat/global-index-db

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrate the symbol index database from per-project ".cora/index.db" to a global shared database at "~/.codecora/cora-code/graph.db" with project_id foreign key scoping.

Changes

Architecture

  • Global DB: All projects share one SQLite database at ~/.codecora/cora-code/graph.db
  • Schema v2: New projects table with project_id FK on files, symbols, call_graph (CASCADE on delete)
  • Auto-create: Project row is created on first index via ensure_project()

Files

File Change
src/data_dir.rs New — resolves ~/.codecora/cora-code/graph.db, CODECORA_DATA_DIR env override
src/index/schema.rs v2 migration, get_or_create_project(), delete_project()
src/index/mod.rs open_global_index()(Connection, i64), all fns accept project_id
src/index/graph.rs find_callers, find_callees, impact_analysis, store_edges, clear_edges_for_file scoped by project_id
src/index/symbols.rs search, like_search, filter_search scoped by project_id
src/main.rs All CLI commands use global index
src/mcp/tools.rs All MCP tools use global index
docs/standards/ CodeCora Data Directory Standard

Breaking Change

Existing per-project .cora/index.db files will be ignored — users need to re-index (cora index --rebuild) after upgrade. This is acceptable since the index feature is Phase 2/pre-stable.

Validation

  • cargo check — 0 errors, 0 warnings
  • cargo clippy — clean
  • cargo test — 703 passed, 0 failed

ajianaz added 2 commits July 22, 2026 15:40
…de/graph.db with project_id scoping

BREAKING CHANGE: index database moved from .cora/index.db (per-project) to ~/.codecora/cora-code/graph.db (global). Schema v2 adds projects table with project_id FK on files, symbols, and call_graph tables. All queries now scoped by project_id.

- Add data_dir module: resolves ~/.codecora/cora-code/graph.db with CODECORA_DATA_DIR env override
- Add schema v2 migration: projects table, project_id FK on files/symbols/call_graph (CASCADE)
- Replace open_index()/default_db_path() with open_global_index() returning (Connection, project_id)
- Update all index functions (search, index_stats, prune_deleted, find_callers, find_callees, impact_analysis, clear_edges_for_file, store_edges) to accept project_id
- Update all CLI commands (Index, Explore, Callers, Impact, Affected) to use global index
- Update all MCP tools to use global index with project scoping
- Remove dead code (open_index, resolve_project_root)
- Add CodeCora Data Directory Standard doc
- All 703 tests pass, 0 clippy warnings
@ajianaz
ajianaz merged commit 83ea2e6 into develop Jul 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant