--- id: 5fb6b3c0-cc6a-4baa-8552-8d2731379b0b type: solution title: "Migration Script: Default-to-Named-Graph Memory Transfer" tags: [cognitive-memory, migration, multi-graph, python, script, solution] importance: 0.85 confidence: 0.8 created: "2026-03-01T22:16:44.476551+00:00" updated: "2026-03-01T22:16:45.908384+00:00" relations: - target: b1ba1b27-d2bf-44f9-a1f5-0ace2017dc18 type: BUILDS_ON direction: incoming strength: 0.7 edge_id: 2adf60cc-84e8-4351-9ea0-1036983c39a1 - target: d0d1a325-a308-474a-baf7-6939a76a136b type: RELATED_TO direction: outgoing strength: 0.79 edge_id: ac0d00ea-f279-49b5-b186-b8c3cc4deffe - target: 9eb16f9f-c825-4233-b64f-d0acd140374a type: RELATED_TO direction: outgoing strength: 0.78 edge_id: 8d2b6329-8e85-4620-be9b-88805105c047 --- # Memory Migration Script: Default to Named Project Graphs ## Location `/mnt/NV2/Development/cognitive-memory/scripts/migrate-memories.py` ## Problem Memories accumulated in the default cognitive-memory graph without project-level separation. Needed a way to migrate them into named project graphs based on tag matching. ## Solution Standalone Python script (`migrate-memories.py`) that migrates memories from the default cognitive-memory graph to named project graphs. ### Key Features - **Tag-based classification**: routes memories to target graphs by matching tags - **Flags**: `--dry-run`, `--no-git`, `--cleanup-overlaps` - **File operations**: moves/copies `.md` files, updates `_index.json`, `_embeddings.json`, `_state.json` in both source and target - **Edge handling**: classifies edges as migrate vs orphan, strips cross-graph edge references from frontmatter - **Overlap detection**: memories tagged for multiple projects are COPIED (not moved) to each target graph; tracked in `_migration_overlaps.json` - **Idempotent**: safe to re-run - **Atomic JSON writes**: via `tempfile + os.replace()` - **Git auto-commit**: commits changes after successful migration ## Git Commit Committed as `11a046f`, closes Gitea issues #4, #5, #6.