MCPcopy Create free account
hub / github.com/MemTensor/MemOS / migrate

Method migrate

packages/memos-core/src/storage/sqlite.ts:21–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 // ─── Schema ───
20
21 private migrate(): void {
22 this.db.exec(`
23 CREATE TABLE IF NOT EXISTS chunks (
24 id TEXT PRIMARY KEY,
25 session_key TEXT NOT NULL,
26 turn_id TEXT NOT NULL,
27 seq INTEGER NOT NULL,
28 role TEXT NOT NULL,
29 content TEXT NOT NULL,
30 kind TEXT NOT NULL DEFAULT 'paragraph',
31 summary TEXT NOT NULL DEFAULT '',
32 created_at INTEGER NOT NULL,
33 updated_at INTEGER NOT NULL
34 );
35
36 CREATE INDEX IF NOT EXISTS idx_chunks_session
37 ON chunks(session_key);
38 CREATE INDEX IF NOT EXISTS idx_chunks_turn
39 ON chunks(session_key, turn_id, seq);
40 CREATE INDEX IF NOT EXISTS idx_chunks_created
41 ON chunks(created_at);
42 CREATE INDEX IF NOT EXISTS idx_chunks_session_created
43 ON chunks(session_key, created_at, seq);
44
45 CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
46 summary,
47 content,
48 content='chunks',
49 content_rowid='rowid',
50 tokenize='trigram'
51 );
52
53 CREATE TRIGGER IF NOT EXISTS chunks_ai AFTER INSERT ON chunks BEGIN
54 INSERT INTO chunks_fts(rowid, summary, content)
55 VALUES (new.rowid, new.summary, new.content);
56 END;
57
58 CREATE TRIGGER IF NOT EXISTS chunks_ad AFTER DELETE ON chunks BEGIN
59 INSERT INTO chunks_fts(chunks_fts, rowid, summary, content)
60 VALUES ('delete', old.rowid, old.summary, old.content);
61 END;
62
63 CREATE TRIGGER IF NOT EXISTS chunks_au AFTER UPDATE ON chunks BEGIN
64 INSERT INTO chunks_fts(chunks_fts, rowid, summary, content)
65 VALUES ('delete', old.rowid, old.summary, old.content);
66 INSERT INTO chunks_fts(rowid, summary, content)
67 VALUES (new.rowid, new.summary, new.content);
68 END;
69
70 CREATE TABLE IF NOT EXISTS embeddings (
71 chunk_id TEXT PRIMARY KEY REFERENCES chunks(id) ON DELETE CASCADE,
72 vector BLOB NOT NULL,
73 dimensions INTEGER NOT NULL,
74 updated_at INTEGER NOT NULL
75 );
76
77 CREATE TABLE IF NOT EXISTS viewer_events (
78 id INTEGER PRIMARY KEY AUTOINCREMENT,

Callers 1

constructorMethod · 0.95

Calls 15

migrateTaskIdMethod · 0.95
migrateContentHashMethod · 0.95
migrateSkillTablesMethod · 0.95
migrateSkillIdMethod · 0.95
migrateTaskSkillMetaMethod · 0.95
migrateToolCallsMethod · 0.95
migrateMergeFieldsMethod · 0.95
migrateApiLogsMethod · 0.95
migrateDedupStatusMethod · 0.95
migrateOwnerFieldsMethod · 0.95

Tested by

no test coverage detected