mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-30 05:29:53 +00:00
add initial stuff
This commit is contained in:
parent
796bbf4d66
commit
8daa6e774a
36 changed files with 1779 additions and 143 deletions
17
internal/db/migrations/000001_initial.up.sql
Normal file
17
internal/db/migrations/000001_initial.up.sql
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-- sqlfluff:dialect:sqlite
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id TEXT PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
message_count INTEGER NOT NULL DEFAULT 0 CHECK (message_count >= 0),
|
||||
tokens INTEGER NOT NULL DEFAULT 0 CHECK (tokens >= 0),
|
||||
cost REAL NOT NULL DEFAULT 0.0 CHECK (cost >= 0.0),
|
||||
updated_at INTEGER NOT NULL, -- Unix timestamp in milliseconds
|
||||
created_at INTEGER NOT NULL -- Unix timestamp in milliseconds
|
||||
);
|
||||
|
||||
CREATE TRIGGER IF NOT EXISTS update_sessions_updated_at
|
||||
AFTER UPDATE ON sessions
|
||||
BEGIN
|
||||
UPDATE sessions SET updated_at = strftime('%s', 'now')
|
||||
WHERE id = new.id;
|
||||
END;
|
||||
Loading…
Add table
Add a link
Reference in a new issue