SQLite Configuration

PRAGMA journal_mode = WAL;      -- Concurrent reads/writes
PRAGMA synchronous = NORMAL;    -- Good perf/durability trade-off
PRAGMA foreign_keys = ON;       -- FK constraints active
PRAGMA temp_store = MEMORY;     -- Temp tables in RAM
PRAGMA mmap_size = 268435456;   -- 256 MB memory-mapped I/O
PRAGMA cache_size = -16000;     -- 16 MB cache

Tables

TablePKKey FieldsNotes
workspacesid TEXTname, slug (unique), profile, color, project_dir, config JSONTrigger: auto-update updated_at
conversationsid TEXTworkspace_id FK, title, pinned, archived, run_count, last_run_idIndex: workspace_id, updated_at DESC
messagesid TEXTconversation_id FK, role, content, content_type, metadata JSONImmutable — no updated_at. role: user|assistant|system|tool|error
run_linksrun_id TEXTconversation_id FK RESTRICT, status, phases JSON, total_cost, total_tokensstatus: running|completed|failed|cancelled|completed_with_errors
sessionsid TEXTtoken_hash (unique), expires_atHourly cleanup of expired sessions
workspace_settings(workspace_id, key)value JSON nullableReserved: auto_summary, default_model, notification_level, max_concurrent_runs
ipc_eventsid TEXTtype, payload JSON, processed booleanAppend-only audit log. 7-day purge of processed events

Migrations

# Generate migration from schema changes
npm run db:generate

# Apply migrations (also runs automatically on server start)
npm run db:migrate

# Config: drizzle.config.js
export default {
  schema: './src/db/schema.js',
  out:    './src/db/migrations',
  dialect: 'sqlite',
  dbCredentials: { url: process.env.ADA_DB_PATH }
}