This commit is contained in:
Storme-bit
2026-08-20 04:26:58 -07:00
parent 565286a4d9
commit 4c00a8d84a
3 changed files with 26 additions and 7 deletions
@@ -16,6 +16,14 @@ const migrations = [
// used to run (wrapped in try/catch) on every boot are folded into schema.js.
// Nothing to do here — this entry exists to mark v1 as the consolidated baseline.
(_db) => {},
(db) => {
db.exec(`
ALTER TABLE episodes ADD COLUMN last_accessed_at INTEGER;
ALTER TABLE episodes ADD COLUMN access_count INTEGER NOT NULL DEFAULT 0;
`)
db.exec(`UPDATE episdoes SET last_accessed_at = created_at WHERE last_accessed_at IS NULL`)
}
];
const LATEST_VERSION = migrations.length;
+9 -7
View File
@@ -15,13 +15,15 @@ const schema = `
);
CREATE TABLE IF NOT EXISTS episodes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id INTEGER NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
user_message TEXT NOT NULL,
ai_response TEXT NOT NULL,
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
token_count INTEGER,
metadata TEXT
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id INTEGER NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
user_message TEXT NOT NULL,
ai_response TEXT NOT NULL,
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
token_count INTEGER,
metadata TEXT,
last_accessed_at INTEGER,
access_count INTEGER NOT NULL DEFAULT 0;
);
CREATE TABLE IF NOT EXISTS entities (