Add db message metadata
This commit is contained in:
@@ -55,7 +55,8 @@ CREATE INDEX IF NOT EXISTS idx_conv_user ON conversations(user_id);
|
||||
-- Messages are ordered entries within a conversation. The content column
|
||||
-- stores the wire-format JSON for the message — the exact JSON object
|
||||
-- that appears in the OpenAI Chat Completions messages array. The role
|
||||
-- column is extracted for querying without JSON parsing. The sequence
|
||||
-- column is extracted for querying without JSON parsing. Nullable metadata
|
||||
-- stores inference JSONB separately from model-visible content. The sequence
|
||||
-- column defines ordering within the conversation. Deleting a message
|
||||
-- cascades to nothing further (all message data is in the row).
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
@@ -63,6 +64,7 @@ CREATE TABLE IF NOT EXISTS messages (
|
||||
content TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
||||
id TEXT PRIMARY KEY,
|
||||
metadata BLOB CHECK (metadata IS NULL OR json_valid(metadata, 8)),
|
||||
role TEXT NOT NULL,
|
||||
sequence INTEGER NOT NULL,
|
||||
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
||||
@@ -149,6 +151,8 @@ CREATE TABLE IF NOT EXISTS executions (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_executions_message ON executions(message_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_executions_pending ON executions(status) WHERE status = 'pending';
|
||||
-- Prevent duplicate execution rows for the same tool call in a message.
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_executions_call ON executions(message_id, tool_call_id);
|
||||
|
||||
-- Default user. Temporary workaround until authentication is built.
|
||||
INSERT INTO users (id, name, password, role)
|
||||
|
||||
Reference in New Issue
Block a user