2-- +goose StatementBegin
4CREATE TABLE IF NOT EXISTS sessions (
6 parent_session_id TEXT,
8 message_count INTEGER NOT NULL DEFAULT 0 CHECK (message_count >= 0),
9 prompt_tokens INTEGER NOT NULL DEFAULT 0 CHECK (prompt_tokens >= 0),
10 completion_tokens INTEGER NOT NULL DEFAULT 0 CHECK (completion_tokens>= 0),
11 cost REAL NOT NULL DEFAULT 0.0 CHECK (cost >= 0.0),
12 updated_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
13 created_at INTEGER NOT NULL -- Unix timestamp in milliseconds
16CREATE TRIGGER IF NOT EXISTS update_sessions_updated_at
17AFTER UPDATE ON sessions
19UPDATE sessions SET updated_at = strftime('%s', 'now')
24CREATE TABLE IF NOT EXISTS files (
26 session_id TEXT NOT NULL,
28 content TEXT NOT NULL,
29 version INTEGER NOT NULL DEFAULT 0,
30 created_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
31 updated_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
32 FOREIGN KEY (session_id) REFERENCES sessions (id) ON DELETE CASCADE,
33 UNIQUE(path, session_id, version)
36CREATE INDEX IF NOT EXISTS idx_files_session_id ON files (session_id);
37CREATE INDEX IF NOT EXISTS idx_files_path ON files (path);
39CREATE TRIGGER IF NOT EXISTS update_files_updated_at
42UPDATE files SET updated_at = strftime('%s', 'now')
47CREATE TABLE IF NOT EXISTS messages (
49 session_id TEXT NOT NULL,
51 parts TEXT NOT NULL default '[]',
53 created_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
54 updated_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
55 finished_at INTEGER, -- Unix timestamp in milliseconds
56 FOREIGN KEY (session_id) REFERENCES sessions (id) ON DELETE CASCADE
59CREATE INDEX IF NOT EXISTS idx_messages_session_id ON messages (session_id);
61CREATE TRIGGER IF NOT EXISTS update_messages_updated_at
62AFTER UPDATE ON messages
64UPDATE messages SET updated_at = strftime('%s', 'now')
68CREATE TRIGGER IF NOT EXISTS update_session_message_count_on_insert
69AFTER INSERT ON messages
72 message_count = message_count + 1
73WHERE id = new.session_id;
76CREATE TRIGGER IF NOT EXISTS update_session_message_count_on_delete
77AFTER DELETE ON messages
80 message_count = message_count - 1
81WHERE id = old.session_id;
87-- +goose StatementBegin
88DROP TRIGGER IF EXISTS update_sessions_updated_at;
89DROP TRIGGER IF EXISTS update_messages_updated_at;
90DROP TRIGGER IF EXISTS update_files_updated_at;
92DROP TRIGGER IF EXISTS update_session_message_count_on_delete;
93DROP TRIGGER IF EXISTS update_session_message_count_on_insert;
95DROP TABLE IF EXISTS sessions;
96DROP TABLE IF EXISTS messages;
97DROP TABLE IF EXISTS files;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list