29 lines
885 B
TypeScript
29 lines
885 B
TypeScript
import type { RawAccess } from "rivetkit/db";
|
|
|
|
// Small inline migration for this isolated actor-local SQLite database.
|
|
export async function migrateMemoryDb(db: RawAccess) {
|
|
await db.execute(`
|
|
CREATE TABLE IF NOT EXISTS memory_files (
|
|
path TEXT PRIMARY KEY NOT NULL,
|
|
content_md TEXT NOT NULL,
|
|
tags_json TEXT NOT NULL,
|
|
created_at INTEGER NOT NULL,
|
|
updated_at INTEGER NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS memory_files_updated_at_idx
|
|
ON memory_files (updated_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS memory_events (
|
|
id TEXT PRIMARY KEY NOT NULL,
|
|
type TEXT NOT NULL CHECK (type IN ('written', 'appended', 'deleted')),
|
|
path TEXT NOT NULL,
|
|
payload_json TEXT,
|
|
created_at INTEGER NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS memory_events_path_created_at_idx
|
|
ON memory_events (path, created_at);
|
|
`);
|
|
}
|