@@ -46,6 +46,7 @@ import {
4646 DDL_ARCHIVE_ACCESS_LOG_IDX ,
4747} from '../../archive/SqlStorageMemoryArchive.js' ;
4848import { migrateV1ToV2 } from './migrations/v1-to-v2.js' ;
49+ import { PORTABLE_TABLES , PORTABLE_TABLE_PRIMARY_KEYS } from './portable-tables.js' ;
4950
5051/**
5152 * Derive a stable brain identifier from the database file path.
@@ -942,51 +943,5 @@ export class Brain {
942943 }
943944}
944945
945- // ---------------------------------------------------------------------------
946- // Portable-artifact constants
947- // ---------------------------------------------------------------------------
948-
949- /**
950- * Tables exported and imported by `Brain.exportToSqlite` / `importFromSqlite`.
951- * Order matters for import: parents before children to satisfy FKs.
952- */
953- const PORTABLE_TABLES = [
954- 'brain_meta' ,
955- 'memory_traces' ,
956- 'knowledge_nodes' ,
957- 'knowledge_edges' ,
958- 'documents' ,
959- 'document_chunks' ,
960- 'document_images' ,
961- 'consolidation_log' ,
962- 'retrieval_feedback' ,
963- 'conversations' ,
964- 'messages' ,
965- 'prospective_items' ,
966- 'archived_traces' ,
967- 'archive_access_log' ,
968- ] as const ;
969-
970- /**
971- * Composite primary key columns for each portable table, used by
972- * `dialect.insertOrReplace` as the conflict target during merge import.
973- *
974- * Tables with `INTEGER PRIMARY KEY AUTOINCREMENT` (consolidation_log,
975- * retrieval_feedback) use `id` alone since their PK is system-generated.
976- */
977- const PORTABLE_TABLE_PRIMARY_KEYS : Record < string , string > = {
978- brain_meta : 'brain_id, key' ,
979- memory_traces : 'brain_id, id' ,
980- knowledge_nodes : 'brain_id, id' ,
981- knowledge_edges : 'brain_id, id' ,
982- documents : 'brain_id, id' ,
983- document_chunks : 'brain_id, id' ,
984- document_images : 'brain_id, id' ,
985- consolidation_log : 'id' ,
986- retrieval_feedback : 'id' ,
987- conversations : 'brain_id, id' ,
988- messages : 'brain_id, id' ,
989- prospective_items : 'brain_id, id' ,
990- archived_traces : 'brain_id, trace_id' ,
991- archive_access_log : 'brain_id, trace_id, accessed_at' ,
992- } ;
946+ // PORTABLE_TABLES + PORTABLE_TABLE_PRIMARY_KEYS moved to ./portable-tables.ts
947+ // (single source of truth shared with v1-to-v2 migration + postgres test cleanup).
0 commit comments