SQL

CREATE TABLE conversation_turns  (
  id TEXT PRIMARY KEY,
  thread_id TEXT NOT NULL,
  role TEXT NOT NULL,
  text TEXT NOT NULL,
  normalized_text TEXT,
  source TEXT NOT NULL DEFAULT 'unknown',
  source_event_id TEXT,
  source_kind TEXT,
  message_id TEXT,
  turn_ts TEXT,
  meta TEXT,
  created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
  updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
  FOREIGN KEY (source_event_id) REFERENCES events(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
id TEXT Rename | Drop
thread_id TEXT Rename | Drop
role TEXT Rename | Drop
text TEXT Rename | Drop
normalized_text TEXT Rename | Drop
source TEXT Rename | Drop
source_event_id TEXT Rename | Drop
source_kind TEXT Rename | Drop
message_id TEXT Rename | Drop
turn_ts TEXT Rename | Drop
meta TEXT Rename | Drop
created_at TEXT Rename | Drop
updated_at TEXT Rename | Drop

Foreign Keys

Column Destination
source_event_id events.id

+ Add index

Indexes

Name Columns Unique SQL Drop?
idx_conversation_turns_source_event source_event_id SQL
CREATE UNIQUE INDEX idx_conversation_turns_source_event
ON conversation_turns (source_event_id) WHERE source_event_id IS NOT NULL
Drop
idx_conversation_turns_thread_created
  • thread_id
  • created_at
SQL
CREATE INDEX idx_conversation_turns_thread_created
ON conversation_turns (thread_id, created_at)
Drop
idx_conversation_turns_thread_turn_ts
  • thread_id
  • turn_ts
SQL
CREATE INDEX idx_conversation_turns_thread_turn_ts
ON conversation_turns (thread_id, turn_ts)
Drop
sqlite_autoindex_conversation_turns_1 id SQL
-- no sql found --
Drop