| export const SCHEMA_MIGRATION = ` |
| CREATE TABLE IF NOT EXISTS memories_v2 ( |
| id TEXT PRIMARY KEY, |
| text TEXT NOT NULL, |
| embedding BLOB NOT NULL, |
| type TEXT NOT NULL DEFAULT 'semantic' CHECK (type IN ('episodic', 'semantic', 'procedural')), |
| source TEXT NOT NULL DEFAULT 'user' CHECK (source IN ('user', 'assistant')), |
| created_at INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000), |
| last_accessed_at INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000), |
| access_count INTEGER NOT NULL DEFAULT 0, |
| importance REAL NOT NULL DEFAULT 0.5 CHECK (importance >= 0 AND importance <= 1), |
| conversation_id TEXT, |
| metadata TEXT |
| ); |
| CREATE INDEX IF NOT EXISTS idx_memories_type ON memories_v2(type); |
| CREATE INDEX IF NOT EXISTS idx_memories_source ON memories_v2(source); |
| CREATE INDEX IF NOT EXISTS idx_memories_created ON memories_v2(created_at DESC); |
| CREATE INDEX IF NOT EXISTS idx_memories_accessed ON memories_v2(last_accessed_at DESC); |
| CREATE INDEX IF NOT EXISTS idx_memories_importance ON memories_v2(importance DESC); |
| `; |
|
|