fix: move cache_tokens/reasoning_tokens ALTER TABLE before view creation
This commit is contained in:
@@ -32,11 +32,18 @@ CREATE TABLE IF NOT EXISTS messages (
|
||||
content TEXT NOT NULL DEFAULT '',
|
||||
status TEXT NOT NULL DEFAULT 'complete',
|
||||
last_seq INT NOT NULL DEFAULT 0,
|
||||
cache_tokens INTEGER,
|
||||
reasoning_tokens INTEGER,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id, created_at);
|
||||
|
||||
-- vDeepSeek: add cache/reasoning token columns early so messages_with_parts
|
||||
-- view (defined below) can reference them. IF NOT EXISTS guards re-runs.
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS cache_tokens INTEGER;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS reasoning_tokens INTEGER;
|
||||
|
||||
-- v1.13.0: granular message parts table. v1.13.20: legacy tool_calls/
|
||||
-- tool_results columns dropped; message_parts is now the sole source of
|
||||
-- truth for tool calls, tool results, and reasoning. ON DELETE CASCADE
|
||||
@@ -204,8 +211,6 @@ ALTER TABLE messages ADD COLUMN IF NOT EXISTS ctx_used INTEGER;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS ctx_max INTEGER;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS started_at TIMESTAMPTZ;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS finished_at TIMESTAMPTZ;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS cache_tokens INTEGER;
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS reasoning_tokens INTEGER;
|
||||
|
||||
ALTER TABLE sessions ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user