{ "activity": { "engine": "assistant", "tables": [] }, "agent_login": { "engine": "sessions", "tables": [] }, "ahead": { "tables": [] }, "ai_budget": { "engine": "ai_usage", "tables": [] }, "ai_calls": { "engine": "ai_usage", "tables": [] }, "ai_daily": { "engine": "ai_usage", "tables": [] }, "alarm": { "engine": "alarms", "tables": [ { "name": "cotton_alarms", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "label", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n label TEXT NOT NULL DEFAULT ''", "position": 2 }, { "name": "hour", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n hour INTEGER NOT NULL", "position": 3 }, { "name": "minute", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n minute INTEGER NOT NULL", "position": 4 }, { "name": "repeat_days", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n repeat_days TEXT NOT NULL DEFAULT '[]'", "position": 5 }, { "name": "enabled", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n enabled INTEGER NOT NULL DEFAULT 1", "position": 6 }, { "name": "sound", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n sound INTEGER NOT NULL DEFAULT 1", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK ((hour >= 0) AND (hour <= 23))", "position": 13 }, { "declaration": "\n CHECK ((minute >= 0) AND (minute <= 59))", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE cotton_alarms (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_alarms_workspace ON cotton_alarms (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_alarms_author ON cotton_alarms (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "album": { "engine": "media", "tables": [ { "name": "cotton_media_albums", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 2 }, { "name": "state", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'open'", "position": 3 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 4 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 5 }, { "name": "title_by", "type": "TEXT", "default": "'derived'", "nullable": false, "primary_key": false, "declaration": "\n title_by TEXT NOT NULL DEFAULT 'derived'", "position": 6 }, { "name": "starts_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n starts_at TEXT NOT NULL", "position": 7 }, { "name": "ends_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n ends_at TEXT NOT NULL", "position": 8 }, { "name": "home_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n home_label TEXT", "position": 9 }, { "name": "cover_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cover_id TEXT", "position": 10 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 11 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 12 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 13 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 14 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 15 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 16 } ], "constraints": [ { "declaration": "\n CHECK (kind IN ('trip', 'event'))", "position": 17 }, { "declaration": "\n CHECK (state IN ('open', 'kept', 'dismissed'))", "position": 18 }, { "declaration": "\n CHECK ((state = 'open') = (decided_at IS NULL))", "position": 19 }, { "declaration": "\n CHECK (title_by IN ('derived', 'user'))", "position": 20 }, { "declaration": "\n CHECK (starts_at <= ends_at)", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 22 } ], "prefix": "CREATE TABLE cotton_media_albums (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_media_albums_open ON cotton_media_albums (workspace_id, starts_at DESC) WHERE state = 'open'", "CREATE INDEX idx_cotton_media_albums_time ON cotton_media_albums (workspace_id, starts_at DESC)", "CREATE INDEX idx_cotton_media_albums_origin ON cotton_media_albums (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_media_albums_author ON cotton_media_albums (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "album_item": { "engine": "media", "tables": [ { "name": "cotton_media_album_items", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "album_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n album_id TEXT NOT NULL", "position": 2 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 3 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 4 }, { "name": "added_by", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n added_by TEXT NOT NULL", "position": 5 }, { "name": "sort_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sort_at TEXT NOT NULL", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n CHECK (record_kind IN ('photo', 'video'))", "position": 12 }, { "declaration": "\n CHECK (substr(record_id, 1, length(record_kind) + 1) = record_kind || ':')", "position": 13 }, { "declaration": "\n CHECK (added_by IN ('derived', 'user'))", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 15 }, { "declaration": "\n FOREIGN KEY (album_id) REFERENCES cotton_media_albums(id)\n ", "position": 16 } ], "prefix": "CREATE TABLE cotton_media_album_items (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_media_album_items_member ON cotton_media_album_items (album_id, record_id)", "CREATE INDEX idx_cotton_media_album_items_record ON cotton_media_album_items (workspace_id, record_id)", "CREATE INDEX idx_cotton_media_album_items_origin ON cotton_media_album_items (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_media_album_items_author ON cotton_media_album_items (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "assistant": { "engine": "assistants", "tables": [ { "name": "cotton_agent_accounts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "provider", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n provider TEXT NOT NULL", "position": 2 }, { "name": "email", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n email TEXT NOT NULL", "position": 3 }, { "name": "label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n label TEXT", "position": 4 }, { "name": "five_hour_pct", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n five_hour_pct REAL", "position": 5 }, { "name": "five_hour_resets_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n five_hour_resets_at TEXT", "position": 6 }, { "name": "weekly_pct", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n weekly_pct REAL", "position": 7 }, { "name": "weekly_resets_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n weekly_resets_at TEXT", "position": 8 }, { "name": "seen_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n seen_at TEXT", "position": 9 }, { "name": "seen_on_device_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n seen_on_device_id TEXT", "position": 10 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 11 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 12 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, provider, email)", "position": 15 }, { "declaration": "\n CHECK (provider IN ('anthropic', 'openai'))", "position": 16 }, { "declaration": "\n CHECK (length(trim(email)) > 0)", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 18 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_agent_accounts (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_agent_accounts_workspace ON cotton_agent_accounts (workspace_id, seen_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_agent_accounts_author ON cotton_agent_accounts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_account_usage_samples", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "account_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n account_id TEXT NOT NULL", "position": 2 }, { "name": "sampled_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sampled_at TEXT NOT NULL", "position": 3 }, { "name": "five_hour_pct", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n five_hour_pct REAL", "position": 4 }, { "name": "weekly_pct", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n weekly_pct REAL", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, account_id, sampled_at)", "position": 8 }, { "declaration": "\n CHECK (length(trim(account_id)) > 0)", "position": 9 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 10 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_account_usage_samples (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_account_usage_samples_account ON cotton_account_usage_samples (workspace_id, account_id, sampled_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_account_usage_samples_author ON cotton_account_usage_samples (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "assistant_call": { "engine": "assistant", "tables": [] }, "assistant_run": { "engine": "assistant", "tables": [ { "name": "cotton_assistant_runs", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "source_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source_kind TEXT NOT NULL CHECK (source_kind IN ('thought','comment','session_message'))", "position": 2 }, { "name": "source_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source_id TEXT NOT NULL", "position": 3 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_kind TEXT", "position": 4 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_id TEXT", "position": 5 }, { "name": "session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n session_id TEXT", "position": 6 }, { "name": "class", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n class TEXT NOT NULL CHECK (class IN ('quick','deep'))", "position": 7 }, { "name": "state", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'queued' CHECK (state IN ('queued','running','done','failed'))", "position": 8 }, { "name": "task", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n task TEXT NOT NULL CHECK (length(task) BETWEEN 1 AND 500)", "position": 9 }, { "name": "receipt", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n receipt TEXT NOT NULL", "position": 10 }, { "name": "turns", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n turns INTEGER NOT NULL DEFAULT 0", "position": 11 }, { "name": "input_tokens", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n input_tokens INTEGER NOT NULL DEFAULT 0", "position": 12 }, { "name": "output_tokens", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n output_tokens INTEGER NOT NULL DEFAULT 0", "position": 13 }, { "name": "cost_usd", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cost_usd REAL", "position": 14 }, { "name": "result_note_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n result_note_id TEXT", "position": 15 }, { "name": "stopped_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n stopped_reason TEXT CHECK (stopped_reason IS NULL OR stopped_reason IN ('answered','turn_ceiling','time_ceiling','no_key','model_refused'))", "position": 16 }, { "name": "error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error TEXT", "position": 17 }, { "name": "queued_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n queued_at TEXT NOT NULL", "position": 18 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n started_at TEXT", "position": 19 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 20 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 21 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 22 } ], "constraints": [ { "declaration": "\n CHECK ((state = 'failed') = (error IS NOT NULL))", "position": 23 }, { "declaration": "\n CHECK ((state IN ('done','failed')) = (finished_at IS NOT NULL))", "position": 24 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 25 } ], "prefix": "CREATE TABLE cotton_assistant_runs (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_assistant_runs_state ON cotton_assistant_runs (workspace_id, state, queued_at)", "CREATE INDEX idx_cotton_assistant_runs_source ON cotton_assistant_runs (source_kind, source_id)", "CREATE INDEX idx_cotton_assistant_runs_note ON cotton_assistant_runs (result_note_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_assistant_runs_author ON cotton_assistant_runs (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "backup": { "engine": "backup", "tables": [] }, "bin": { "engine": "bin", "tables": [] }, "board": { "engine": "boards", "tables": [] }, "briefing": { "engine": "memory", "tables": [] }, "call": { "engine": "calls", "tables": [ { "name": "cotton_call_log", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 2 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_id TEXT NOT NULL", "position": 3 }, { "name": "provider", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n provider TEXT NOT NULL", "position": 4 }, { "name": "direction", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n direction TEXT NOT NULL", "position": 5 }, { "name": "outcome", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n outcome TEXT NOT NULL", "position": 6 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n started_at TEXT NOT NULL", "position": 7 }, { "name": "duration_s", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n duration_s INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n handle TEXT", "position": 9 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n contact_id TEXT", "position": 10 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 11 }, { "name": "device", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n device TEXT", "position": 12 }, { "name": "meta", "type": "TEXT", "default": "'{}'", "nullable": false, "primary_key": false, "declaration": "\n meta TEXT NOT NULL DEFAULT '{}'", "position": 13 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 14 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 15 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 16 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 17 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, source, external_id)", "position": 18 }, { "declaration": "\n CHECK (direction IN ('in', 'out'))", "position": 19 }, { "declaration": "\n CHECK (outcome IN ('answered', 'missed', 'cancelled', 'failed'))", "position": 20 }, { "declaration": "\n CHECK (length(trim(external_id)) > 0)", "position": 21 }, { "declaration": "\n CHECK (length(trim(provider)) > 0)", "position": 22 }, { "declaration": "\n CHECK (duration_s >= 0)", "position": 23 }, { "declaration": "\n CHECK (json_type(meta) = 'object')", "position": 24 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 25 } ], "prefix": "CREATE TABLE cotton_call_log (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_call_log_started ON cotton_call_log (workspace_id, started_at DESC)", "CREATE INDEX idx_cotton_call_log_person ON cotton_call_log (person_id)", "CREATE INDEX idx_cotton_call_log_contact ON cotton_call_log (contact_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_call_log_author ON cotton_call_log (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "camera": { "engine": "camera", "tables": [] }, "code_credential": { "engine": "code", "tables": [ { "name": "cotton_code_credentials", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n device_id TEXT NOT NULL CHECK (length(trim(device_id)) > 0)", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL CHECK (length(trim(name)) > 0)", "position": 3 }, { "name": "scope", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n scope TEXT NOT NULL CHECK (scope IN ('device', 'script', 'runner'))", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "expires_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n expires_at TEXT", "position": 6 }, { "name": "revoked_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n revoked_at TEXT", "position": 7 }, { "name": "last_used_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_used_at TEXT", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 }, { "name": "token_digest", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n token_digest TEXT", "position": 11 }, { "name": "minted_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n minted_by TEXT", "position": 12 }, { "name": "read_only", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " read_only INTEGER NOT NULL DEFAULT 0", "position": 13 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_code_credentials (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_code_credentials_workspace ON cotton_code_credentials (workspace_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_code_credentials_author ON cotton_code_credentials (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "code_default": { "engine": "code", "tables": [] }, "code_runner": { "engine": "code", "tables": [ { "name": "cotton_machine_runners", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n device_id TEXT NOT NULL CHECK (length(trim(device_id)) > 0)", "position": 2 }, { "name": "enabled", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1))", "position": 3 }, { "name": "labels_json", "type": "TEXT", "default": "'[\"cotton-checks-mac:host\"]'", "nullable": false, "primary_key": false, "declaration": "\n labels_json TEXT NOT NULL DEFAULT '[\"cotton-checks-mac:host\"]'", "position": 4 }, { "name": "capacity", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n capacity INTEGER NOT NULL DEFAULT 1 CHECK (capacity BETWEEN 1 AND 4)", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 }, { "name": "ai_levels", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": " ai_levels TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(ai_levels) AND json(ai_levels) IN ('[]', '[1]', '[2]', '[3]', '[1,2]', '[1,3]', '[2,1]', '[2,3]', '[3,1]', '[3,2]', '[1,2,3]', '[1,3,2]', '[2,1,3]', '[2,3,1]', '[3,1,2]', '[3,2,1]'))", "position": 10 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, device_id)", "position": 11 }, { "declaration": "\n CHECK (json_type(labels_json) = 'array')", "position": 12 }, { "declaration": "\n CHECK (json_array_length(labels_json) BETWEEN 1 AND 3)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_machine_runners (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_machine_runners_device ON cotton_machine_runners (workspace_id, device_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_machine_runners_author ON cotton_machine_runners (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "comment": { "engine": "comments", "tables": [ { "name": "cotton_comments", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 2 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 3 }, { "name": "parent_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n parent_id TEXT", "position": 4 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 5 }, { "name": "author_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n author_kind TEXT NOT NULL", "position": 6 }, { "name": "author_user_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_user_id TEXT", "position": 7 }, { "name": "author_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_label TEXT", "position": 8 }, { "name": "anchor", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n anchor TEXT", "position": 9 }, { "name": "resolved_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_at TEXT", "position": 10 }, { "name": "resolved_by_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_by_kind TEXT", "position": 11 }, { "name": "resolved_by_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_by_label TEXT", "position": 12 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 13 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 14 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 15 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 16 }, { "name": "kind", "type": "TEXT", "default": "'note'", "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL DEFAULT 'note'", "position": 17 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n CHECK (kind IN ('question', 'note'))", "position": 19 }, { "declaration": "\n CHECK ((author_kind = 'agent') = (author_label IS NOT NULL))", "position": 20 }, { "declaration": "\n CHECK (author_kind IN ('user', 'agent'))", "position": 21 }, { "declaration": "\n CHECK (length(trim(body)) > 0)", "position": 22 }, { "declaration": "\n CHECK (record_kind IN ('todo', 'event', 'note', 'journal', 'person', 'location', 'page', 'meeting', 'document', 'news_edition', 'memory', 'call', 'decision'))", "position": 23 }, { "declaration": "\n CHECK (resolved_by_kind IN ('user', 'agent'))", "position": 24 }, { "declaration": "\n CHECK ((resolved_at IS NULL) = (resolved_by_kind IS NULL))", "position": 25 }, { "declaration": "\n CHECK ((author_kind = 'user') = (author_user_id IS NOT NULL))", "position": 26 }, { "declaration": "\n FOREIGN KEY (parent_id) REFERENCES cotton_comments(id)", "position": 27 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 28 } ], "prefix": "CREATE TABLE \"cotton_comments\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_comments_open ON cotton_comments (workspace_id, created_at DESC) WHERE resolved_at IS NULL", "CREATE INDEX idx_cotton_comments_parent ON cotton_comments (parent_id) WHERE parent_id IS NOT NULL", "CREATE INDEX idx_cotton_comments_record ON cotton_comments (record_kind, record_id, created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_comments_author ON cotton_comments (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "commit": { "engine": "repos", "tables": [] }, "connection": { "engine": "connections", "tables": [] }, "copy": { "engine": "sync", "tables": [] }, "database": { "engine": "databases", "tables": [] }, "database_archive": { "tables": [] }, "decision": { "engine": "decisions", "tables": [ { "name": "cotton_decisions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 2 }, { "name": "why", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n why TEXT", "position": 3 }, { "name": "pull", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n pull TEXT", "position": 4 }, { "name": "decided_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_by TEXT", "position": 5 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n CHECK (length(trim(title)) > 0)", "position": 11 }, { "declaration": "\n CHECK (length(title) <= 280)", "position": 12 }, { "declaration": "\n CHECK (pull IS NULL OR length(trim(pull)) > 0)", "position": 13 }, { "declaration": "\n CHECK (decided_by IS NULL OR length(trim(decided_by)) > 0)", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_decisions (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_decisions_author ON cotton_decisions (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_decisions USING fts5(\n title, why, content = 'cotton_decisions', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_decisions_ai AFTER INSERT ON cotton_decisions WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_decisions'), 0) BEGIN\n INSERT INTO fts_decisions (rowid, title, why) VALUES (new.rowid, new.title, new.why);\n END", "CREATE TRIGGER fts_decisions_ad AFTER DELETE ON cotton_decisions WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_decisions'), 0) BEGIN\n INSERT INTO fts_decisions (fts_decisions, rowid, title, why) VALUES ('delete', old.rowid, old.title, old.why);\n END", "CREATE TRIGGER fts_decisions_au AFTER UPDATE OF title, why ON cotton_decisions\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_decisions'), 0) AND (new.title IS NOT old.title OR new.why IS NOT old.why) BEGIN\n INSERT INTO fts_decisions (fts_decisions, rowid, title, why) VALUES ('delete', old.rowid, old.title, old.why);\n INSERT INTO fts_decisions (rowid, title, why) VALUES (new.rowid, new.title, new.why);\n END" ] } ] }, "device": { "engine": "devices", "tables": [] }, "document": { "engine": "documents", "tables": [ { "name": "cotton_document_pages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "document_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n document_id TEXT NOT NULL", "position": 1 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 2 }, { "name": "page", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n page INTEGER NOT NULL", "position": 3 }, { "name": "text", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n text TEXT NOT NULL", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n UNIQUE (document_id, page)", "position": 8 }, { "declaration": "\n CHECK (page >= 1)", "position": 9 }, { "declaration": "\n FOREIGN KEY (document_id) REFERENCES cotton_documents(id)", "position": 10 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 11 } ], "prefix": "CREATE TABLE cotton_document_pages (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_document_pages_workspace ON cotton_document_pages (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_document_pages_author ON cotton_document_pages (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_document_pages USING fts5(\n text, content = 'cotton_document_pages', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_document_pages_ai AFTER INSERT ON cotton_document_pages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_document_pages'), 0) BEGIN\n INSERT INTO fts_document_pages (rowid, text) VALUES (new.rowid, new.text);\n END", "CREATE TRIGGER fts_document_pages_ad AFTER DELETE ON cotton_document_pages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_document_pages'), 0) BEGIN\n INSERT INTO fts_document_pages (fts_document_pages, rowid, text) VALUES ('delete', old.rowid, old.text);\n END", "CREATE TRIGGER fts_document_pages_au AFTER UPDATE OF text ON cotton_document_pages\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_document_pages'), 0) AND (new.text IS NOT old.text) BEGIN\n INSERT INTO fts_document_pages (fts_document_pages, rowid, text) VALUES ('delete', old.rowid, old.text);\n INSERT INTO fts_document_pages (rowid, text) VALUES (new.rowid, new.text);\n END" ] }, { "name": "cotton_documents", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 2 }, { "name": "original_name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n original_name TEXT NOT NULL", "position": 3 }, { "name": "mime", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n mime TEXT NOT NULL", "position": 4 }, { "name": "byte_size", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n byte_size INTEGER NOT NULL", "position": 5 }, { "name": "sha256", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha256 TEXT NOT NULL", "position": 6 }, { "name": "storage_path", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n storage_path TEXT NOT NULL", "position": 7 }, { "name": "decrypted_path", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decrypted_path TEXT", "position": 8 }, { "name": "password", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n password TEXT", "position": 9 }, { "name": "page_count", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n page_count INTEGER", "position": 10 }, { "name": "status", "type": "TEXT", "default": "'processing'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'processing'", "position": 11 }, { "name": "failed_stage", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n failed_stage TEXT", "position": 12 }, { "name": "error_code", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error_code TEXT", "position": 13 }, { "name": "status_changed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n status_changed_at TEXT", "position": 14 }, { "name": "doc_type", "type": "TEXT", "default": "'other'", "nullable": false, "primary_key": false, "declaration": "\n doc_type TEXT NOT NULL DEFAULT 'other'", "position": 15 }, { "name": "document_date", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n document_date TEXT", "position": 16 }, { "name": "period_start", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_start TEXT", "position": 17 }, { "name": "period_end", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_end TEXT", "position": 18 }, { "name": "issuer", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n issuer TEXT", "position": 19 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 20 }, { "name": "facts", "type": "TEXT", "default": "'{}'", "nullable": false, "primary_key": false, "declaration": "\n facts TEXT NOT NULL DEFAULT '{}'", "position": 21 }, { "name": "text_extracted", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n text_extracted INTEGER NOT NULL DEFAULT 0", "position": 22 }, { "name": "source", "type": "TEXT", "default": "'app'", "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL DEFAULT 'app'", "position": 23 }, { "name": "mcp_token_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n mcp_token_id TEXT", "position": 24 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 25 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 26 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 27 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 28 }, { "name": "secret_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " secret_id TEXT", "position": 29 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 30 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 31 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, sha256)", "position": 32 }, { "declaration": "\n CHECK (byte_size >= 0)", "position": 33 }, { "declaration": "\n CHECK (doc_type IN ('bank_statement', 'card_statement', 'invoice', 'receipt', 'tax', 'id', 'insurance', 'medical', 'legal', 'ticket', 'statement_other', 'letter', 'manual', 'other'))", "position": 34 }, { "declaration": "\n CHECK ((status = 'failed') = (failed_stage IS NOT NULL))", "position": 35 }, { "declaration": "\n CHECK (failed_stage IS NULL OR failed_stage IN ('unlock', 'extract', 'summarize', 'land'))", "position": 36 }, { "declaration": "\n CHECK ((page_count IS NULL) OR (page_count >= 0))", "position": 37 }, { "declaration": "\n CHECK ((period_start IS NULL) OR (period_end IS NULL) OR (period_end >= period_start))", "position": 38 }, { "declaration": "\n CHECK (length(sha256) = 64 AND NOT sha256 GLOB '*[^0-9a-f]*')", "position": 39 }, { "declaration": "\n CHECK (source IN ('app', 'agent', 'share'))", "position": 40 }, { "declaration": "\n CHECK (status IN ('processing', 'summarizing', 'ready', 'locked', 'failed'))", "position": 41 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 42 } ], "prefix": "CREATE TABLE \"cotton_documents\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_documents_pipeline ON cotton_documents (status, status_changed_at) WHERE status IN ('processing', 'summarizing')", "CREATE INDEX idx_cotton_documents_type ON cotton_documents (workspace_id, doc_type)", "CREATE INDEX idx_cotton_documents_workspace_date ON cotton_documents (workspace_id, document_date DESC, created_at DESC)", "CREATE INDEX idx_cotton_documents_origin ON cotton_documents (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_documents_author ON cotton_documents (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_documents USING fts5(\n title, issuer, summary, original_name, content = 'cotton_documents', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_documents_ai AFTER INSERT ON cotton_documents WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_documents'), 0) BEGIN\n INSERT INTO fts_documents (rowid, title, issuer, summary, original_name) VALUES (new.rowid, new.title, new.issuer, new.summary, new.original_name);\n END", "CREATE TRIGGER fts_documents_ad AFTER DELETE ON cotton_documents WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_documents'), 0) BEGIN\n INSERT INTO fts_documents (fts_documents, rowid, title, issuer, summary, original_name) VALUES ('delete', old.rowid, old.title, old.issuer, old.summary, old.original_name);\n END", "CREATE TRIGGER fts_documents_au AFTER UPDATE OF title, issuer, summary, original_name ON cotton_documents\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_documents'), 0) AND (new.title IS NOT old.title OR new.issuer IS NOT old.issuer OR new.summary IS NOT old.summary OR new.original_name IS NOT old.original_name) BEGIN\n INSERT INTO fts_documents (fts_documents, rowid, title, issuer, summary, original_name) VALUES ('delete', old.rowid, old.title, old.issuer, old.summary, old.original_name);\n INSERT INTO fts_documents (rowid, title, issuer, summary, original_name) VALUES (new.rowid, new.title, new.issuer, new.summary, new.original_name);\n END" ] } ] }, "duplicate": { "engine": "media", "tables": [ { "name": "cotton_media_duplicates", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 2 }, { "name": "keep_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n keep_id TEXT NOT NULL", "position": 3 }, { "name": "copy_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n copy_id TEXT NOT NULL", "position": 4 }, { "name": "distance", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n distance INTEGER NOT NULL", "position": 5 }, { "name": "method", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n method TEXT NOT NULL", "position": 6 }, { "name": "state", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'open'", "position": 7 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK (record_kind IN ('photo', 'video'))", "position": 13 }, { "declaration": "\n CHECK (keep_id <> copy_id)", "position": 14 }, { "declaration": "\n CHECK (substr(keep_id, 1, length(record_kind) + 1) = record_kind || ':')", "position": 15 }, { "declaration": "\n CHECK (substr(copy_id, 1, length(record_kind) + 1) = record_kind || ':')", "position": 16 }, { "declaration": "\n CHECK (distance >= 0 AND distance <= 64)", "position": 17 }, { "declaration": "\n CHECK (method IN ('phash', 'featureprint'))", "position": 18 }, { "declaration": "\n CHECK (state IN ('open', 'confirmed', 'dismissed'))", "position": 19 }, { "declaration": "\n CHECK ((state = 'open') = (decided_at IS NULL))", "position": 20 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 21 } ], "prefix": "CREATE TABLE cotton_media_duplicates (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_media_duplicates_pair ON cotton_media_duplicates (workspace_id, keep_id, copy_id)", "CREATE INDEX idx_cotton_media_duplicates_open ON cotton_media_duplicates (workspace_id, keep_id) WHERE state = 'open'", "CREATE INDEX idx_cotton_media_duplicates_copy ON cotton_media_duplicates (workspace_id, copy_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_media_duplicates_author ON cotton_media_duplicates (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "email": { "engine": "email", "tables": [ { "name": "cotton_emails", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_id TEXT NOT NULL", "position": 3 }, { "name": "subject", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n subject TEXT", "position": 4 }, { "name": "from_email", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n from_email TEXT NOT NULL", "position": 5 }, { "name": "from_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n from_name TEXT", "position": 6 }, { "name": "recipients", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n recipients TEXT NOT NULL DEFAULT '[]'", "position": 7 }, { "name": "sent_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sent_at TEXT NOT NULL", "position": 8 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 9 }, { "name": "snippet", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n snippet TEXT", "position": 10 }, { "name": "attachments", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n attachments TEXT NOT NULL DEFAULT '[]'", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 13 }, { "name": "gmail_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " gmail_id TEXT", "position": 14 }, { "name": "gmail_account", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " gmail_account TEXT", "position": 15 }, { "name": "labels", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " labels TEXT CHECK (labels IS NULL OR json_type(labels) = 'array')", "position": 16 }, { "name": "unread", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " unread INTEGER NOT NULL DEFAULT 0", "position": 17 }, { "name": "starred", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " starred INTEGER NOT NULL DEFAULT 0", "position": 18 }, { "name": "in_inbox", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": " in_inbox INTEGER NOT NULL DEFAULT 1", "position": 19 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 20 }, { "name": "sync_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " sync_state TEXT CHECK (sync_state IS NULL OR sync_state IN ('synced', 'pending'))", "position": 21 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 22 }, { "name": "account", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n account TEXT", "position": 23 }, { "name": "to_line", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " to_line TEXT", "position": 24 }, { "name": "cc_line", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " cc_line TEXT", "position": 25 }, { "name": "direction", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " direction TEXT", "position": 26 }, { "name": "message_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " message_id TEXT", "position": 27 }, { "name": "message_refs", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " message_refs TEXT", "position": 28 }, { "name": "list_unsubscribe", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " list_unsubscribe TEXT", "position": 29 }, { "name": "list_unsubscribe_post", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " list_unsubscribe_post TEXT", "position": 30 }, { "name": "list_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " list_id TEXT", "position": 31 }, { "name": "precedence", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " precedence TEXT", "position": 32 }, { "name": "auto_submitted", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " auto_submitted TEXT", "position": 33 }, { "name": "gmail_category", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " gmail_category TEXT", "position": 34 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " archived_at TEXT", "position": 35 }, { "name": "landed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " landed_at TEXT", "position": 36 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, external_id)", "position": 37 }, { "declaration": "\n CHECK (length(external_id) > 0)", "position": 38 }, { "declaration": "\n CHECK (length(from_email) > 0)", "position": 39 }, { "declaration": "\n CHECK (json_type(recipients) = 'array')", "position": 40 }, { "declaration": "\n CHECK (json_type(attachments) = 'array')", "position": 41 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_email_threads(id)", "position": 42 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 43 } ], "prefix": "CREATE TABLE cotton_emails (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_emails_binned ON cotton_emails (workspace_id,trashed_at) WHERE trashed_at IS NOT NULL", "CREATE INDEX idx_cotton_emails_thread_sent ON cotton_emails (thread_id, sent_at DESC)", "CREATE INDEX idx_cotton_emails_workspace ON cotton_emails (workspace_id)", "CREATE INDEX idx_cotton_emails_account ON cotton_emails (workspace_id, account) WHERE account IS NOT NULL", "CREATE INDEX idx_cotton_emails_gmail_id ON cotton_emails (workspace_id, gmail_id)", "CREATE INDEX idx_cotton_emails_from ON cotton_emails (workspace_id, from_email)", "CREATE INDEX idx_cotton_emails_pending ON cotton_emails (workspace_id, sync_state)\n WHERE sync_state = 'pending'", "CREATE INDEX idx_cotton_emails_account_live ON cotton_emails (workspace_id, lower(coalesce(account, gmail_account)), trashed_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_emails_sender_id ON cotton_emails (workspace_id, lower(trim(from_email)), sent_at, from_name, trashed_at, from_email, id)", "CREATE INDEX idx_cotton_emails_thread_live ON cotton_emails (thread_id, trashed_at, in_inbox, starred, unread)", "CREATE INDEX IF NOT EXISTS idx_cotton_emails_inbox ON cotton_emails (workspace_id, lower(trim(from_email)), sent_at, created_at, id, thread_id, from_email, trashed_at, archived_at, in_inbox) WHERE trashed_at IS NULL AND archived_at IS NULL AND coalesce(in_inbox, 1) <> 0", "CREATE INDEX IF NOT EXISTS idx_cotton_emails_archived ON cotton_emails (thread_id) WHERE trashed_at IS NULL AND (archived_at IS NOT NULL OR in_inbox = 0)", "CREATE INDEX IF NOT EXISTS idx_cotton_emails_files ON cotton_emails (workspace_id, sent_at, id) WHERE trashed_at IS NULL AND attachments IS NOT NULL AND attachments <> '' AND attachments <> '[]'", "CREATE INDEX IF NOT EXISTS idx_cotton_emails_author ON cotton_emails (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_emails USING fts5(\n subject, body, content = 'cotton_emails', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )", "CREATE VIRTUAL TABLE fts_mail USING fts5(\n subject, body, from_name, from_email, content = 'cotton_emails', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_emails_ai AFTER INSERT ON cotton_emails WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_emails'), 0) BEGIN\n INSERT INTO fts_emails (rowid, subject, body) VALUES (new.rowid, new.subject, new.body);\n END", "CREATE TRIGGER fts_emails_ad AFTER DELETE ON cotton_emails WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_emails'), 0) BEGIN\n INSERT INTO fts_emails (fts_emails, rowid, subject, body) VALUES ('delete', old.rowid, old.subject, old.body);\n END", "CREATE TRIGGER fts_emails_au AFTER UPDATE OF subject, body ON cotton_emails\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_emails'), 0) AND (new.subject IS NOT old.subject OR new.body IS NOT old.body) BEGIN\n INSERT INTO fts_emails (fts_emails, rowid, subject, body) VALUES ('delete', old.rowid, old.subject, old.body);\n INSERT INTO fts_emails (rowid, subject, body) VALUES (new.rowid, new.subject, new.body);\n END", "CREATE TRIGGER fts_mail_ai AFTER INSERT ON cotton_emails WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_mail'), 0) BEGIN\n INSERT INTO fts_mail (rowid, subject, body, from_name, from_email) VALUES (new.rowid, new.subject, new.body, new.from_name, new.from_email);\n END", "CREATE TRIGGER fts_mail_ad AFTER DELETE ON cotton_emails WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_mail'), 0) BEGIN\n INSERT INTO fts_mail (fts_mail, rowid, subject, body, from_name, from_email) VALUES ('delete', old.rowid, old.subject, old.body, old.from_name, old.from_email);\n END", "CREATE TRIGGER fts_mail_au AFTER UPDATE OF subject, body, from_name, from_email ON cotton_emails\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_mail'), 0) AND (new.subject IS NOT old.subject OR new.body IS NOT old.body OR new.from_name IS NOT old.from_name OR new.from_email IS NOT old.from_email) BEGIN\n INSERT INTO fts_mail (fts_mail, rowid, subject, body, from_name, from_email) VALUES ('delete', old.rowid, old.subject, old.body, old.from_name, old.from_email);\n INSERT INTO fts_mail (rowid, subject, body, from_name, from_email) VALUES (new.rowid, new.subject, new.body, new.from_name, new.from_email);\n END", "CREATE TRIGGER IF NOT EXISTS _mail_landed_made AFTER INSERT ON cotton_emails WHEN NEW.landed_at IS NOT NULL BEGIN INSERT INTO _mail_landed (id, landed_at, \"key\", domain) VALUES (NEW.id, NEW.landed_at, cotton_mail_key(NEW.from_email), substr(cotton_mail_key(NEW.from_email), instr(cotton_mail_key(NEW.from_email), '@'))) ON CONFLICT (id) DO UPDATE SET landed_at = excluded.landed_at, \"key\" = excluded.\"key\", domain = excluded.domain; END", "CREATE TRIGGER IF NOT EXISTS _mail_landed_changed AFTER UPDATE OF landed_at, from_email ON cotton_emails WHEN NEW.landed_at IS NOT NULL BEGIN INSERT INTO _mail_landed (id, landed_at, \"key\", domain) VALUES (NEW.id, NEW.landed_at, cotton_mail_key(NEW.from_email), substr(cotton_mail_key(NEW.from_email), instr(cotton_mail_key(NEW.from_email), '@'))) ON CONFLICT (id) DO UPDATE SET landed_at = excluded.landed_at, \"key\" = excluded.\"key\", domain = excluded.domain; END", "CREATE TRIGGER IF NOT EXISTS _mail_landed_gone AFTER DELETE ON cotton_emails BEGIN DELETE FROM _mail_landed WHERE id = OLD.id; END" ] }, { "name": "cotton_email_participants", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "email", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n email TEXT NOT NULL", "position": 3 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n display_name TEXT", "position": 4 }, { "name": "role", "type": "TEXT", "default": "'cc'", "nullable": false, "primary_key": false, "declaration": "\n role TEXT NOT NULL DEFAULT 'cc'", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n UNIQUE (thread_id, email)", "position": 10 }, { "declaration": "\n CHECK (length(email) > 0)", "position": 11 }, { "declaration": "\n CHECK (email = lower(email))", "position": 12 }, { "declaration": "\n CHECK (role IN ('from', 'to', 'cc'))", "position": 13 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_email_threads(id)", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE cotton_email_participants (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_email_participants_email ON cotton_email_participants (workspace_id, email)", "CREATE INDEX idx_cotton_email_participants_thread ON cotton_email_participants (thread_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_email_participants_author ON cotton_email_participants (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "email_sender": { "engine": "email", "tables": [ { "name": "cotton_blocked_senders", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "address", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n address TEXT NOT NULL", "position": 2 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 3 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 4 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 5 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, address)", "position": 6 }, { "declaration": "\n CHECK (length(address) > 0)", "position": 7 }, { "declaration": "\n CHECK (address = lower(address))", "position": 8 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 9 } ], "prefix": "CREATE TABLE cotton_blocked_senders (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_blocked_senders_address ON cotton_blocked_senders (workspace_id, address)", "CREATE INDEX IF NOT EXISTS idx_cotton_blocked_senders_author ON cotton_blocked_senders (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_email_senders", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "address", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n address TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 3 }, { "name": "written_to", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n written_to INTEGER NOT NULL DEFAULT 0", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 }, { "name": "decided_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_by TEXT CHECK (decided_by IS NULL OR decided_by IN ('owner', 'assistant'))", "position": 9 }, { "name": "verdict", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n verdict TEXT CHECK (verdict IS NULL OR verdict IN ('person', 'service', 'junk'))", "position": 10 }, { "name": "reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reason TEXT", "position": 11 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, address)", "position": 13 }, { "declaration": "\n CHECK (length(address) > 0)", "position": 14 }, { "declaration": "\n CHECK (address = lower(address))", "position": 15 }, { "declaration": "\n CHECK (kind IN ('person', 'service', 'junk'))", "position": 16 }, { "declaration": "\n CHECK (written_to IN (0, 1))", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 18 } ], "prefix": "CREATE TABLE cotton_email_senders (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_email_senders_author ON cotton_email_senders (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "email_thread": { "engine": "email", "tables": [ { "name": "cotton_email_threads", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "external_key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_key TEXT NOT NULL", "position": 2 }, { "name": "subject", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n subject TEXT", "position": 3 }, { "name": "first_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n first_at TEXT", "position": 4 }, { "name": "last_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_at TEXT", "position": 5 }, { "name": "email_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n email_count INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 7 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_updated_at TEXT", "position": 8 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 }, { "name": "sender_address", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_address TEXT", "position": 15 }, { "name": "sender_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_kind TEXT", "position": 16 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_kind TEXT", "position": 17 }, { "name": "amount_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n amount_minor INTEGER", "position": 18 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n currency TEXT", "position": 19 }, { "name": "merchant", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n merchant TEXT", "position": 20 }, { "name": "record_on", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_on TEXT", "position": 21 }, { "name": "reference", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reference TEXT", "position": 22 }, { "name": "record_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_reason TEXT", "position": 23 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, external_key)", "position": 24 }, { "declaration": "\n CHECK ((record_kind IS NULL) OR (record_kind IN ('receipt', 'statement', 'ticket', 'booking', 'code', 'delivery', 'notice')))", "position": 25 }, { "declaration": "\n CHECK ((currency IS NULL) OR (length(currency) = 3 AND currency = upper(currency)))", "position": 26 }, { "declaration": "\n CHECK ((record_on IS NULL) OR (record_on GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'))", "position": 27 }, { "declaration": "\n CHECK ((sender_address IS NULL) OR (sender_address = lower(sender_address) AND length(sender_address) > 0))", "position": 28 }, { "declaration": "\n CHECK ((sender_kind IS NULL) OR (sender_kind IN ('person', 'service', 'junk')))", "position": 29 }, { "declaration": "\n CHECK (length(external_key) > 0)", "position": 30 }, { "declaration": "\n CHECK (email_count >= 0)", "position": 31 }, { "declaration": "\n CHECK ((summary IS NULL) OR (length(summary) <= 4000))", "position": 32 }, { "declaration": "\n CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 33 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 34 } ], "prefix": "CREATE TABLE cotton_email_threads (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_email_threads_workspace_recent ON cotton_email_threads (workspace_id, last_at DESC)", "CREATE INDEX idx_cotton_email_threads_sender_kind ON cotton_email_threads (workspace_id, sender_kind, last_at DESC)", "CREATE INDEX idx_cotton_email_threads_sender ON cotton_email_threads (workspace_id, sender_address) WHERE sender_address IS NOT NULL", "CREATE INDEX idx_cotton_email_threads_record_kind ON cotton_email_threads (workspace_id, record_kind, last_at DESC) WHERE record_kind IS NOT NULL", "CREATE INDEX idx_cotton_email_threads_merchant ON cotton_email_threads (workspace_id, id, merchant, trashed_at) WHERE merchant IS NOT NULL AND trashed_at IS NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_email_threads_author ON cotton_email_threads (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "event": { "engine": "calendar", "tables": [ { "name": "cotton_events", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "collection_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n collection_id TEXT", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 2 }, { "name": "notes", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n notes TEXT", "position": 3 }, { "name": "starts_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n starts_at TEXT NOT NULL", "position": 4 }, { "name": "ends_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ends_at TEXT", "position": 5 }, { "name": "all_day", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n all_day INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "rrule", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n rrule TEXT", "position": 7 }, { "name": "location", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n location TEXT", "position": 8 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 9 }, { "name": "gcal_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n gcal_id TEXT", "position": 10 }, { "name": "gcal_etag", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n gcal_etag TEXT", "position": 11 }, { "name": "sync_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sync_state TEXT", "position": 12 }, { "name": "organizer_is_self", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n organizer_is_self INTEGER NOT NULL DEFAULT 1", "position": 13 }, { "name": "my_response", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n my_response TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "series_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " series_id TEXT", "position": 18 }, { "name": "original_starts_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " original_starts_at TEXT", "position": 19 }, { "name": "exdates", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " exdates TEXT CHECK (exdates IS NULL OR json_type(exdates) = 'array')", "position": 20 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 21 }, { "name": "erase_requested_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n erase_requested_at TEXT", "position": 22 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 23 }, { "name": "ical_uid", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ical_uid TEXT", "position": 24 }, { "name": "account", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n account TEXT", "position": 25 }, { "name": "on_google", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n on_google INTEGER NOT NULL DEFAULT 0", "position": 26 }, { "name": "event_place", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " event_place TEXT", "position": 27 }, { "name": "country", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " country TEXT", "position": 28 }, { "name": "timezone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " timezone TEXT", "position": 29 } ], "constraints": [ { "declaration": "\n CHECK (on_google IN (0, 1))", "position": 30 }, { "declaration": "\n CHECK (my_response IN ('needs_action', 'accepted', 'declined', 'tentative'))", "position": 31 }, { "declaration": "\n CHECK (sync_state IN ('synced', 'pending', 'conflict'))\n ", "position": 32 } ], "prefix": "CREATE TABLE cotton_events (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_events_invites ON cotton_events (my_response, starts_at) WHERE my_response = 'needs_action' AND organizer_is_self = 0 AND trashed_at IS NULL", "CREATE INDEX idx_cotton_events_collection ON cotton_events (collection_id)", "CREATE INDEX idx_cotton_events_range ON cotton_events (starts_at)", "CREATE UNIQUE INDEX uq_cotton_events_gcal_id ON cotton_events (account, gcal_id) WHERE gcal_id IS NOT NULL", "CREATE INDEX idx_cotton_events_series ON cotton_events (series_id) WHERE series_id IS NOT NULL", "CREATE INDEX idx_cotton_events_trashed ON cotton_events (trashed_at) WHERE trashed_at IS NOT NULL", "CREATE INDEX idx_cotton_events_ical_uid ON cotton_events (ical_uid, original_starts_at) WHERE ical_uid IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_events_author ON cotton_events (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_events USING fts5(\n title, notes, location, content = 'cotton_events', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_events_ai AFTER INSERT ON cotton_events WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) BEGIN\n INSERT INTO fts_events (rowid, title, notes, location) VALUES (new.rowid, new.title, new.notes, new.location);\n END", "CREATE TRIGGER fts_events_ad AFTER DELETE ON cotton_events WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) BEGIN\n INSERT INTO fts_events (fts_events, rowid, title, notes, location) VALUES ('delete', old.rowid, old.title, old.notes, old.location);\n END", "CREATE TRIGGER fts_events_au AFTER UPDATE OF title, notes, location ON cotton_events\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) AND (new.title IS NOT old.title OR new.notes IS NOT old.notes OR new.location IS NOT old.location) BEGIN\n INSERT INTO fts_events (fts_events, rowid, title, notes, location) VALUES ('delete', old.rowid, old.title, old.notes, old.location);\n INSERT INTO fts_events (rowid, title, notes, location) VALUES (new.rowid, new.title, new.notes, new.location);\n END" ] }, { "name": "cotton_event_attendees", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "event_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n event_id TEXT NOT NULL", "position": 1 }, { "name": "email", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n email TEXT", "position": 2 }, { "name": "phone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n phone TEXT", "position": 3 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n display_name TEXT", "position": 4 }, { "name": "response", "type": "TEXT", "default": "'needs_action'", "nullable": false, "primary_key": false, "declaration": "\n response TEXT NOT NULL DEFAULT 'needs_action'", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n CHECK (response IN ('needs_action', 'accepted', 'declined', 'tentative'))", "position": 10 }, { "declaration": "\n FOREIGN KEY (event_id) REFERENCES cotton_events(id)\n ", "position": 11 } ], "prefix": "CREATE TABLE cotton_event_attendees (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_event_attendees_event ON cotton_event_attendees (event_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_event_attendees_author ON cotton_event_attendees (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "everything": { "engine": "everything", "tables": [] }, "evidence": { "engine": "money", "tables": [ { "name": "cotton_money_evidence", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "transaction_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n transaction_id TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 3 }, { "name": "ref_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ref_id TEXT", "position": 4 }, { "name": "excerpt", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n excerpt TEXT NOT NULL", "position": 5 }, { "name": "source_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_label TEXT", "position": 6 }, { "name": "attached_by", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n attached_by TEXT NOT NULL", "position": 7 }, { "name": "attached_by_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n attached_by_label TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK (attached_by IN ('import', 'assistant', 'owner'))", "position": 13 }, { "declaration": "\n CHECK (kind IN ('statement_line', 'document', 'message', 'email', 'external'))", "position": 14 }, { "declaration": "\n CHECK ((kind = 'external') OR (ref_id IS NOT NULL))", "position": 15 }, { "declaration": "\n FOREIGN KEY (transaction_id) REFERENCES cotton_money_transactions(id)", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE cotton_money_evidence (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_money_evidence_ref ON cotton_money_evidence (kind, ref_id)", "CREATE INDEX idx_cotton_money_evidence_transaction ON cotton_money_evidence (transaction_id)", "CREATE INDEX idx_cotton_money_evidence_workspace ON cotton_money_evidence (workspace_id)", "CREATE UNIQUE INDEX uq_cotton_money_evidence_line ON cotton_money_evidence (ref_id) WHERE kind = 'statement_line'", "CREATE UNIQUE INDEX uq_cotton_money_evidence_ref ON cotton_money_evidence (transaction_id, kind, ref_id) WHERE ref_id IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_money_evidence_author ON cotton_money_evidence (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "face": { "engine": "photos", "tables": [ { "name": "cotton_media_faces", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 2 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 3 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 4 }, { "name": "source_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source_id TEXT NOT NULL", "position": 5 }, { "name": "x", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n x REAL NOT NULL", "position": 6 }, { "name": "y", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n y REAL NOT NULL", "position": 7 }, { "name": "w", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n w REAL NOT NULL", "position": 8 }, { "name": "h", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n h REAL NOT NULL", "position": 9 }, { "name": "quality", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n quality REAL", "position": 10 }, { "name": "cluster_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cluster_id TEXT", "position": 11 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 12 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 13 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 14 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 15 }, { "name": "suggested_person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " suggested_person_id TEXT", "position": 16 }, { "name": "suggested_distance", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": " suggested_distance REAL CHECK (suggested_distance IS NULL OR (suggested_distance >= 0 AND suggested_distance <= 2))", "position": 17 }, { "name": "suggestion_dismissed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " suggestion_dismissed_at TEXT", "position": 18 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 19 }, { "name": "embedding", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " embedding TEXT CHECK (embedding IS NULL OR length(embedding) > 0)", "position": 20 }, { "name": "embedding_model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " embedding_model TEXT CHECK (embedding_model IS NULL OR length(embedding_model) > 0)", "position": 21 }, { "name": "person_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " person_by TEXT CHECK (person_by IS NULL OR person_by = 'match')", "position": 22 } ], "constraints": [ { "declaration": "\n CHECK (record_kind IN ('photo', 'video'))", "position": 23 }, { "declaration": "\n CHECK (substr(record_id, 1, length(record_kind) + 1) = record_kind || ':')", "position": 24 }, { "declaration": "\n CHECK (source IN ('apple', 'cotton'))", "position": 25 }, { "declaration": "\n CHECK (x >= 0 AND x <= 1 AND y >= 0 AND y <= 1)", "position": 26 }, { "declaration": "\n CHECK (w > 0 AND w <= 1 AND h > 0 AND h <= 1)", "position": 27 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 28 } ], "prefix": "CREATE TABLE cotton_media_faces (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_media_faces_natural ON cotton_media_faces (workspace_id, record_kind, record_id, source, source_id)", "CREATE INDEX idx_cotton_media_faces_record ON cotton_media_faces (workspace_id, record_id)", "CREATE INDEX idx_cotton_media_faces_person ON cotton_media_faces (workspace_id, person_id) WHERE person_id IS NOT NULL", "CREATE INDEX idx_cotton_media_faces_cluster ON cotton_media_faces (workspace_id, cluster_id) WHERE cluster_id IS NOT NULL", "CREATE INDEX idx_cotton_media_faces_suggested ON cotton_media_faces (workspace_id, suggested_person_id) WHERE suggested_person_id IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_media_faces_author ON cotton_media_faces (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "feedback": { "engine": "feedback", "tables": [ { "name": "cotton_feedback", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "image_sha256", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n image_sha256 TEXT", "position": 2 }, { "name": "image_ext", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n image_ext TEXT", "position": 3 }, { "name": "x", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n x REAL", "position": 4 }, { "name": "y", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n y REAL", "position": 5 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 6 }, { "name": "author_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n author_kind TEXT NOT NULL", "position": 7 }, { "name": "author_user_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_user_id TEXT", "position": 8 }, { "name": "author_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_label TEXT", "position": 9 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 10 }, { "name": "same_as", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n same_as TEXT", "position": 11 }, { "name": "share_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n share_id TEXT", "position": 12 }, { "name": "app", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n app TEXT", "position": 13 }, { "name": "context", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n context TEXT", "position": 14 }, { "name": "status", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'open'", "position": 15 }, { "name": "resolved_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_at TEXT", "position": 16 }, { "name": "resolved_by_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_by_kind TEXT", "position": 17 }, { "name": "resolved_by_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolved_by_label TEXT", "position": 18 }, { "name": "resolution_note", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n resolution_note TEXT", "position": 19 }, { "name": "parent_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n parent_id TEXT", "position": 20 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 21 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 22 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 23 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 24 } ], "constraints": [ { "declaration": "\n CHECK ((image_sha256 IS NULL) OR (app IS NOT NULL))", "position": 25 }, { "declaration": "\n CHECK ((image_sha256 IS NULL) = (image_ext IS NULL))", "position": 26 }, { "declaration": "\n CHECK ((x IS NULL) = (y IS NULL))", "position": 27 }, { "declaration": "\n CHECK ((x IS NULL) OR (app IS NULL) OR (image_sha256 IS NOT NULL))", "position": 28 }, { "declaration": "\n CHECK (length(trim(body)) > 0)", "position": 29 }, { "declaration": "\n CHECK (author_kind IN ('user', 'agent', 'guest'))", "position": 30 }, { "declaration": "\n CHECK ((author_kind = 'user') = (author_user_id IS NOT NULL))", "position": 31 }, { "declaration": "\n CHECK ((author_kind = 'user') OR (author_label IS NOT NULL))", "position": 32 }, { "declaration": "\n CHECK (same_as IS NULL OR same_as <> id)", "position": 33 }, { "declaration": "\n CHECK ((same_as IS NULL) OR (parent_id IS NULL))", "position": 34 }, { "declaration": "\n CHECK (context IS NULL OR json_type(context) = 'object')", "position": 35 }, { "declaration": "\n CHECK (status IN ('open', 'agreed', 'declined', 'shipped', 'resolved', 'dismissed'))", "position": 36 }, { "declaration": "\n CHECK (resolved_by_kind IN ('user', 'agent'))", "position": 37 }, { "declaration": "\n FOREIGN KEY (parent_id) REFERENCES cotton_feedback(id)", "position": 38 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 39 } ], "prefix": "CREATE TABLE \"cotton_feedback\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_feedback_open ON cotton_feedback (workspace_id, created_at DESC) WHERE resolved_at IS NULL", "CREATE INDEX idx_cotton_feedback_parent ON cotton_feedback (parent_id) WHERE parent_id IS NOT NULL", "CREATE INDEX idx_cotton_feedback_capture ON cotton_feedback (workspace_id, app, created_at) WHERE app IS NOT NULL", "CREATE INDEX idx_cotton_feedback_person ON cotton_feedback (person_id, created_at) WHERE person_id IS NOT NULL", "CREATE INDEX idx_cotton_feedback_same_as ON cotton_feedback (same_as) WHERE same_as IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_feedback_author ON cotton_feedback (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "filing_proposal": { "engine": "filing", "tables": [ { "name": "cotton_filing_proposals", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "owner", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n owner TEXT NOT NULL", "position": 2 }, { "name": "session", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n session TEXT NOT NULL", "position": 3 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 4 }, { "name": "destination", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n destination TEXT NOT NULL", "position": 5 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL CHECK(kind IN ('move','capture'))", "position": 6 }, { "name": "candidates", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n candidates TEXT NOT NULL CHECK(json_valid(candidates) AND json_type(candidates)='array')", "position": 7 }, { "name": "arrivals", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n arrivals TEXT NOT NULL CHECK(json_valid(arrivals) AND json_type(arrivals)='array')", "position": 8 }, { "name": "revisions", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n revisions TEXT NOT NULL CHECK(json_valid(revisions) AND json_type(revisions)='object')", "position": 9 }, { "name": "payload", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n payload TEXT NOT NULL CHECK(json_valid(payload) AND json_type(payload)='object')", "position": 10 }, { "name": "reason", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n reason TEXT NOT NULL", "position": 11 }, { "name": "status", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'open' CHECK(status IN ('open','approved','declined','stale'))", "position": 12 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 13 }, { "name": "answer", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n answer TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n FOREIGN KEY(workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n", "position": 19 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_filing_proposals (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_filing_proposals_open ON cotton_filing_proposals(workspace_id,status,created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_filing_proposals_author ON cotton_filing_proposals(substr(_hlc,20),_hlc)" ], "full_text": [], "triggers": [] } ] }, "goal": { "engine": "goals", "tables": [ { "name": "cotton_goals", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 2 }, { "name": "why", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n why TEXT", "position": 3 }, { "name": "target_date", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n target_date TEXT", "position": 4 }, { "name": "status", "type": "TEXT", "default": "'active'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'active'", "position": 5 }, { "name": "achieved_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n achieved_at TEXT", "position": 6 }, { "name": "sort_order", "type": "REAL", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sort_order REAL NOT NULL DEFAULT 0", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK ((status = 'achieved') = (achieved_at IS NOT NULL))", "position": 13 }, { "declaration": "\n CHECK (status IN ('active', 'paused', 'achieved', 'dropped'))", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE cotton_goals (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_goals_workspace_status ON cotton_goals (workspace_id, status, sort_order)", "CREATE INDEX IF NOT EXISTS idx_cotton_goals_author ON cotton_goals (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "import": { "engine": "imports", "tables": [] }, "issue": { "engine": "repos", "tables": [ { "name": "cotton_repo_issues", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "number", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n number INTEGER NOT NULL", "position": 3 }, { "name": "remote_id", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_id INTEGER", "position": 4 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 5 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 6 }, { "name": "state", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL", "position": 7 }, { "name": "author", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author TEXT", "position": 8 }, { "name": "labels", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n labels TEXT NOT NULL DEFAULT '[]'", "position": 9 }, { "name": "comments_count", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n comments_count INTEGER", "position": 10 }, { "name": "html_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n html_url TEXT", "position": 11 }, { "name": "remote_created_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_created_at TEXT", "position": 12 }, { "name": "remote_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_updated_at TEXT", "position": 13 }, { "name": "closed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n closed_at TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, number)", "position": 19 }, { "declaration": "\n CHECK (state IN ('open', 'closed'))", "position": 20 }, { "declaration": "\n CHECK (json_type(labels) = 'array')", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 22 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 23 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_issues (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_issues_repo ON cotton_repo_issues (workspace_id, repo_id, state, remote_updated_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_issues_author ON cotton_repo_issues (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_repo_issues USING fts5(\n title, body, content = 'cotton_repo_issues', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_repo_issues_ai AFTER INSERT ON cotton_repo_issues WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_issues'), 0) BEGIN\n INSERT INTO fts_repo_issues (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END", "CREATE TRIGGER fts_repo_issues_ad AFTER DELETE ON cotton_repo_issues WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_issues'), 0) BEGIN\n INSERT INTO fts_repo_issues (fts_repo_issues, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n END", "CREATE TRIGGER fts_repo_issues_au AFTER UPDATE OF title, body ON cotton_repo_issues\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_issues'), 0) AND (new.title IS NOT old.title OR new.body IS NOT old.body) BEGIN\n INSERT INTO fts_repo_issues (fts_repo_issues, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n INSERT INTO fts_repo_issues (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END" ] } ] }, "job": { "engine": "ci", "tables": [] }, "journal": { "engine": "journal", "tables": [] }, "lines": { "tables": [] }, "location": { "engine": "locations", "tables": [ { "name": "cotton_locations", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 2 }, { "name": "address", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n address TEXT", "position": 3 }, { "name": "lat", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n lat REAL", "position": 4 }, { "name": "lng", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n lng REAL", "position": 5 }, { "name": "note", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n note TEXT", "position": 6 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 13 }, { "name": "place", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " place TEXT", "position": 14 }, { "name": "place_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " place_id TEXT", "position": 15 }, { "name": "country", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " country TEXT", "position": 16 }, { "name": "timezone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " timezone TEXT", "position": 17 }, { "name": "near", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " near TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 19 } ], "prefix": "CREATE TABLE cotton_locations (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_locations_workspace ON cotton_locations (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_locations_author ON cotton_locations (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_locations USING fts5(\n name, address, note, content = 'cotton_locations', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_locations_ai AFTER INSERT ON cotton_locations WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) BEGIN\n INSERT INTO fts_locations (rowid, name, address, note) VALUES (new.rowid, new.name, new.address, new.note);\n END", "CREATE TRIGGER fts_locations_ad AFTER DELETE ON cotton_locations WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) BEGIN\n INSERT INTO fts_locations (fts_locations, rowid, name, address, note) VALUES ('delete', old.rowid, old.name, old.address, old.note);\n END", "CREATE TRIGGER fts_locations_au AFTER UPDATE OF name, address, note ON cotton_locations\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) AND (new.name IS NOT old.name OR new.address IS NOT old.address OR new.note IS NOT old.note) BEGIN\n INSERT INTO fts_locations (fts_locations, rowid, name, address, note) VALUES ('delete', old.rowid, old.name, old.address, old.note);\n INSERT INTO fts_locations (rowid, name, address, note) VALUES (new.rowid, new.name, new.address, new.note);\n END" ] } ] }, "machine_runner": { "engine": "code", "tables": [] }, "media": { "engine": "media", "tables": [] }, "meeting": { "engine": "meetings", "tables": [ { "name": "cotton_meetings", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 2 }, { "name": "status", "type": "TEXT", "default": "'uploading'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'uploading'", "position": 3 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 4 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n started_at TEXT NOT NULL", "position": 5 }, { "name": "ended_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ended_at TEXT", "position": 6 }, { "name": "duration_seconds", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n duration_seconds INTEGER", "position": 7 }, { "name": "language", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n language TEXT", "position": 8 }, { "name": "event_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n event_id TEXT", "position": 9 }, { "name": "speakers", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n speakers TEXT NOT NULL DEFAULT '[]'", "position": 10 }, { "name": "summary_md", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_md TEXT", "position": 11 }, { "name": "decisions", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n decisions TEXT NOT NULL DEFAULT '[]'", "position": 12 }, { "name": "vendor", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n vendor TEXT", "position": 13 }, { "name": "vendor_job_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n vendor_job_id TEXT", "position": 14 }, { "name": "poll_attempts", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n poll_attempts INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "status_changed_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n status_changed_at TEXT NOT NULL", "position": 16 }, { "name": "audio_deleted_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n audio_deleted_at TEXT", "position": 17 }, { "name": "failed_stage", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n failed_stage TEXT", "position": 18 }, { "name": "error_code", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error_code TEXT", "position": 19 }, { "name": "segments", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n segments TEXT NOT NULL DEFAULT '[]'", "position": 20 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 21 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 22 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 23 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 24 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 25 }, { "name": "event_database", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n event_database TEXT CHECK (event_database IS NULL OR length(event_database) > 0)", "position": 26 } ], "constraints": [ { "declaration": "\n CHECK ((duration_seconds IS NULL) OR (duration_seconds >= 0))", "position": 27 }, { "declaration": "\n CHECK ((status = 'failed') = (failed_stage IS NOT NULL))", "position": 28 }, { "declaration": "\n CHECK (failed_stage IS NULL OR failed_stage IN ('submit', 'transcribe', 'summarize'))", "position": 29 }, { "declaration": "\n CHECK (poll_attempts >= 0)", "position": 30 }, { "declaration": "\n CHECK (source IN ('recorded', 'imported'))", "position": 31 }, { "declaration": "\n CHECK (status IN ('recording', 'uploading', 'queued', 'transcribing', 'summarizing', 'ready', 'failed'))", "position": 32 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 33 } ], "prefix": "CREATE TABLE cotton_meetings (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_meetings_event ON cotton_meetings (event_id) WHERE event_id IS NOT NULL", "CREATE INDEX idx_cotton_meetings_pipeline ON cotton_meetings (status, status_changed_at) WHERE status IN ('transcribing', 'summarizing')", "CREATE INDEX idx_cotton_meetings_workspace_started ON cotton_meetings (workspace_id, started_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_meetings_author ON cotton_meetings (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_meetings USING fts5(\n title, summary_md, content = 'cotton_meetings', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_meetings_ai AFTER INSERT ON cotton_meetings WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) BEGIN\n INSERT INTO fts_meetings (rowid, title, summary_md) VALUES (new.rowid, new.title, new.summary_md);\n END", "CREATE TRIGGER fts_meetings_ad AFTER DELETE ON cotton_meetings WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) BEGIN\n INSERT INTO fts_meetings (fts_meetings, rowid, title, summary_md) VALUES ('delete', old.rowid, old.title, old.summary_md);\n END", "CREATE TRIGGER fts_meetings_au AFTER UPDATE OF title, summary_md ON cotton_meetings\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) AND (new.title IS NOT old.title OR new.summary_md IS NOT old.summary_md) BEGIN\n INSERT INTO fts_meetings (fts_meetings, rowid, title, summary_md) VALUES ('delete', old.rowid, old.title, old.summary_md);\n INSERT INTO fts_meetings (rowid, title, summary_md) VALUES (new.rowid, new.title, new.summary_md);\n END" ] }, { "name": "cotton_meeting_utterances", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "meeting_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n meeting_id TEXT NOT NULL", "position": 1 }, { "name": "seq", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n seq INTEGER NOT NULL", "position": 2 }, { "name": "speaker_label", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n speaker_label TEXT NOT NULL", "position": 3 }, { "name": "t0_ms", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n t0_ms INTEGER NOT NULL", "position": 4 }, { "name": "t1_ms", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n t1_ms INTEGER NOT NULL", "position": 5 }, { "name": "text", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n text TEXT NOT NULL", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n UNIQUE (meeting_id, seq)", "position": 10 }, { "declaration": "\n CHECK (seq >= 0)", "position": 11 }, { "declaration": "\n CHECK (t1_ms >= t0_ms)", "position": 12 }, { "declaration": "\n CHECK (t0_ms >= 0)", "position": 13 }, { "declaration": "\n CHECK (t1_ms >= 0)", "position": 14 }, { "declaration": "\n FOREIGN KEY (meeting_id) REFERENCES cotton_meetings(id)\n ", "position": 15 } ], "prefix": "CREATE TABLE cotton_meeting_utterances (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_meeting_utterances_meeting ON cotton_meeting_utterances (meeting_id, seq)", "CREATE INDEX IF NOT EXISTS idx_cotton_meeting_utterances_author ON cotton_meeting_utterances (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "member": { "engine": "members", "tables": [] }, "memory": { "engine": "memory", "tables": [ { "name": "cotton_memory_projects", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "slug", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n slug TEXT NOT NULL", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 3 }, { "name": "repos", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n repos TEXT NOT NULL DEFAULT '[]'", "position": 4 }, { "name": "brand", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n brand TEXT CHECK (brand IS NULL OR json_type(brand) = 'object')", "position": 5 }, { "name": "description", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n description TEXT", "position": 6 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_updated_at TEXT", "position": 7 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 8 }, { "name": "status", "type": "TEXT", "default": "'active'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'active'", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 }, { "name": "section_order", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n section_order TEXT CHECK (section_order IS NULL OR json_type(section_order) = 'array')", "position": 15 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 16 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, slug)", "position": 17 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 18 }, { "declaration": "\n CHECK (json_type(repos) = 'array')", "position": 19 }, { "declaration": "\n CHECK (length(slug) BETWEEN 1 AND 64 AND slug GLOB '[a-z0-9]*' AND NOT slug GLOB '*[^a-z0-9-]*')", "position": 20 }, { "declaration": "\n CHECK (status IN ('active', 'archived'))", "position": 21 }, { "declaration": "\n CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 22 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 23 } ], "prefix": "CREATE TABLE cotton_memory_projects (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_memory_projects_origin ON cotton_memory_projects (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_memory_projects_author ON cotton_memory_projects (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_memories", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "slug", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n slug TEXT NOT NULL", "position": 2 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 3 }, { "name": "body", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL DEFAULT ''", "position": 4 }, { "name": "status", "type": "TEXT", "default": "'active'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'active'", "position": 5 }, { "name": "machine", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n machine TEXT", "position": 6 }, { "name": "visibility", "type": "TEXT", "default": "'private'", "nullable": false, "primary_key": false, "declaration": "\n visibility TEXT NOT NULL DEFAULT 'private'", "position": 7 }, { "name": "origin_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n origin_kind TEXT NOT NULL", "position": 8 }, { "name": "origin_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n origin_label TEXT", "position": 9 }, { "name": "reviewed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reviewed_at TEXT", "position": 10 }, { "name": "source_external_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_external_id TEXT", "position": 11 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 12 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 13 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 14 }, { "name": "source", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source TEXT", "position": 15 }, { "name": "superseded_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n superseded_by TEXT CHECK (superseded_by IS NULL OR status = 'archived')", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n CHECK ((status = 'archived') = (archived_at IS NOT NULL))", "position": 19 }, { "declaration": "\n CHECK (length(body) <= 4000)", "position": 20 }, { "declaration": "\n CHECK ((machine IS NULL) OR (length(trim(machine)) > 0))", "position": 21 }, { "declaration": "\n CHECK (origin_kind IN ('user', 'agent'))", "position": 22 }, { "declaration": "\n CHECK ((origin_kind = 'agent') = (origin_label IS NOT NULL))", "position": 23 }, { "declaration": "\n CHECK (length(slug) BETWEEN 1 AND 64 AND slug GLOB '[a-z0-9]*' AND NOT slug GLOB '*[^a-z0-9-]*')", "position": 24 }, { "declaration": "\n CHECK (status IN ('active', 'archived'))", "position": 25 }, { "declaration": "\n CHECK ((length(trim(title)) > 0) AND (length(title) <= 280))", "position": 26 }, { "declaration": "\n CHECK (visibility IN ('private', 'shared', 'public'))", "position": 27 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 28 } ], "prefix": "CREATE TABLE \"cotton_memories\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_memories_glance ON cotton_memories (workspace_id,status,visibility,origin_kind,reviewed_at,created_at,id,title)", "CREATE UNIQUE INDEX idx_cotton_memories_slug ON cotton_memories (workspace_id, slug)", "CREATE UNIQUE INDEX idx_cotton_memories_source_external ON cotton_memories (workspace_id, source_external_id) WHERE source_external_id IS NOT NULL", "CREATE INDEX idx_cotton_memories_superseded_by ON cotton_memories (superseded_by) WHERE superseded_by IS NOT NULL", "CREATE INDEX idx_cotton_memories_unreviewed ON cotton_memories (workspace_id, updated_at DESC) WHERE (status = 'active') AND (reviewed_at IS NULL)", "CREATE INDEX IF NOT EXISTS idx_cotton_memories_author ON cotton_memories (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_memories USING fts5(\n title, body, content = 'cotton_memories', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_memories_ai AFTER INSERT ON cotton_memories WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_memories'), 0) BEGIN\n INSERT INTO fts_memories (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END", "CREATE TRIGGER fts_memories_ad AFTER DELETE ON cotton_memories WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_memories'), 0) BEGIN\n INSERT INTO fts_memories (fts_memories, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n END", "CREATE TRIGGER fts_memories_au AFTER UPDATE OF title, body ON cotton_memories\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_memories'), 0) AND (new.title IS NOT old.title OR new.body IS NOT old.body) BEGIN\n INSERT INTO fts_memories (fts_memories, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n INSERT INTO fts_memories (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END" ] } ] }, "message": { "engine": "messages", "tables": [ { "name": "cotton_msg_messages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 1 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 2 }, { "name": "direction", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n direction TEXT NOT NULL", "position": 3 }, { "name": "channel", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n channel TEXT NOT NULL", "position": 4 }, { "name": "origin", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n origin TEXT NOT NULL", "position": 5 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 6 }, { "name": "media", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n media TEXT NOT NULL DEFAULT '[]'", "position": 7 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_id TEXT", "position": 8 }, { "name": "sent_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sent_at TEXT NOT NULL", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "read_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_at TEXT", "position": 11 }, { "name": "reply_to_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reply_to_id TEXT", "position": 12 }, { "name": "reply_to_external_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reply_to_external_id TEXT", "position": 13 }, { "name": "reactions", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n reactions TEXT NOT NULL DEFAULT '[]'", "position": 14 }, { "name": "meta", "type": "TEXT", "default": "'{}'", "nullable": false, "primary_key": false, "declaration": "\n meta TEXT NOT NULL DEFAULT '{}'", "position": 15 }, { "name": "sender_contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_contact_id TEXT", "position": 16 }, { "name": "sender_participant_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_participant_id TEXT", "position": 17 }, { "name": "seq", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n seq INTEGER", "position": 18 }, { "name": "edited_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n edited_at TEXT", "position": 19 }, { "name": "deleted_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n deleted_at TEXT", "position": 20 }, { "name": "forward_of_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n forward_of_id TEXT", "position": 21 }, { "name": "mentions", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n mentions TEXT NOT NULL DEFAULT '[]'", "position": 22 }, { "name": "starred_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n starred_at TEXT", "position": 23 }, { "name": "hidden_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n hidden_at TEXT", "position": 24 }, { "name": "send_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n send_state TEXT", "position": 25 }, { "name": "send_error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n send_error TEXT", "position": 26 }, { "name": "send_attempts", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n send_attempts INTEGER NOT NULL DEFAULT 0", "position": 27 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 28 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 29 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 30 } ], "constraints": [ { "declaration": "\n CHECK (channel IN ('cotton', 'whatsapp', 'imessage', 'sms', 'instagram'))", "position": 31 }, { "declaration": "\n CHECK (send_state IS NULL OR send_state IN ('queued', 'sending', 'sent', 'delivered', 'read', 'failed'))", "position": 32 }, { "declaration": "\n CHECK (direction IN ('in', 'out'))", "position": 33 }, { "declaration": "\n CHECK (json_type(media) = 'array')", "position": 34 }, { "declaration": "\n CHECK (json_type(meta) = 'object')", "position": 35 }, { "declaration": "\n CHECK (origin IN ('live', 'imported'))", "position": 36 }, { "declaration": "\n CHECK (json_type(reactions) = 'array')", "position": 37 }, { "declaration": "\n CHECK (json_type(mentions) = 'array')", "position": 38 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 39 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 40 } ], "prefix": "CREATE TABLE \"cotton_msg_messages\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_messages_unread_cursor ON cotton_msg_messages (thread_id, seq, sent_at) WHERE direction = 'in' AND origin = 'live' AND hidden_at IS NULL AND trashed_at IS NULL", "CREATE INDEX idx_cotton_msg_messages_thread_sent ON cotton_msg_messages (thread_id, sent_at DESC)", "CREATE INDEX idx_cotton_msg_messages_expires ON cotton_msg_messages (json_extract(meta, '$.cotton.expiresAt')) WHERE json_extract(meta, '$.cotton.expiresAt') IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_timer ON cotton_msg_messages (thread_id, sent_at DESC) WHERE json_extract(meta, '$.cotton.timer') IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_unread ON cotton_msg_messages (workspace_id, thread_id) WHERE read_at IS NULL", "CREATE INDEX idx_cotton_msg_messages_unresolved_reply ON cotton_msg_messages (thread_id, reply_to_external_id) WHERE (reply_to_external_id IS NOT NULL) AND (reply_to_id IS NULL)", "CREATE UNIQUE INDEX uq_cotton_msg_messages_external ON cotton_msg_messages (thread_id, channel, external_id) WHERE external_id IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_channel_external ON cotton_msg_messages (workspace_id, channel, external_id) WHERE external_id IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_sender_participant ON cotton_msg_messages (sender_participant_id)", "CREATE INDEX idx_cotton_msg_messages_thread_seq ON cotton_msg_messages (thread_id, seq)", "CREATE INDEX idx_cotton_msg_messages_thread_channel ON cotton_msg_messages (thread_id, channel)", "CREATE INDEX idx_cotton_msg_messages_source_account ON cotton_msg_messages (workspace_id, channel, json_extract(meta, '$.source.account')) WHERE deleted_at IS NULL AND hidden_at IS NULL AND json_extract(meta, '$.source.account') IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_starred ON cotton_msg_messages (workspace_id, starred_at) WHERE starred_at IS NOT NULL", "CREATE INDEX idx_cotton_msg_messages_thread_created ON cotton_msg_messages (thread_id, created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_messages_outbox ON cotton_msg_messages (channel, created_at, id) WHERE send_state IN ('queued', 'sending')", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_messages_author ON cotton_msg_messages (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_messages USING fts5(\n body, content = 'cotton_msg_messages', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )", "CREATE VIRTUAL TABLE fts_chat USING fts5(\n body, content = 'cotton_msg_messages', content_rowid = 'rowid',\n tokenize = 'trigram'\n )" ], "triggers": [ "CREATE TRIGGER fts_messages_ai AFTER INSERT ON cotton_msg_messages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_messages'), 0) BEGIN\n INSERT INTO fts_messages (rowid, body) VALUES (new.rowid, new.body);\n END", "CREATE TRIGGER fts_messages_ad AFTER DELETE ON cotton_msg_messages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_messages'), 0) BEGIN\n INSERT INTO fts_messages (fts_messages, rowid, body) VALUES ('delete', old.rowid, old.body);\n END", "CREATE TRIGGER fts_messages_au AFTER UPDATE OF body ON cotton_msg_messages\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_messages'), 0) AND (new.body IS NOT old.body) BEGIN\n INSERT INTO fts_messages (fts_messages, rowid, body) VALUES ('delete', old.rowid, old.body);\n INSERT INTO fts_messages (rowid, body) VALUES (new.rowid, new.body);\n END", "CREATE TRIGGER fts_chat_ai AFTER INSERT ON cotton_msg_messages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_chat'), 0) BEGIN\n INSERT INTO fts_chat (rowid, body) VALUES (new.rowid, new.body);\n END", "CREATE TRIGGER fts_chat_ad AFTER DELETE ON cotton_msg_messages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_chat'), 0) BEGIN\n INSERT INTO fts_chat (fts_chat, rowid, body) VALUES ('delete', old.rowid, old.body);\n END", "CREATE TRIGGER fts_chat_au AFTER UPDATE OF body ON cotton_msg_messages\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_chat'), 0) AND (new.body IS NOT old.body) BEGIN\n INSERT INTO fts_chat (fts_chat, rowid, body) VALUES ('delete', old.rowid, old.body);\n INSERT INTO fts_chat (rowid, body) VALUES (new.rowid, new.body);\n END" ] } ] }, "message_import": { "engine": "messages", "tables": [] }, "money_account": { "engine": "money", "tables": [ { "name": "cotton_money_accounts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 2 }, { "name": "subtype", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n subtype TEXT NOT NULL", "position": 3 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 4 }, { "name": "counterparty_person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n counterparty_person_id TEXT", "position": 5 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n currency TEXT NOT NULL", "position": 6 }, { "name": "institution", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n institution TEXT", "position": 7 }, { "name": "number_mask", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n number_mask TEXT", "position": 8 }, { "name": "is_default", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n is_default INTEGER NOT NULL DEFAULT 0", "position": 9 }, { "name": "is_pooled", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n is_pooled INTEGER CHECK (is_pooled IS NULL OR is_pooled IN (0,1))", "position": 10 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 13 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 14 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 15 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 16 } ], "constraints": [ { "declaration": "\n CHECK (subtype IN ('bank', 'cash', 'credit_card', 'wallet', 'receivable', 'payable', 'loan', 'lent_out', 'fixed_asset'))", "position": 17 }, { "declaration": "\n FOREIGN KEY (counterparty_person_id) REFERENCES cotton_people(id)", "position": 18 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 19 } ], "prefix": "CREATE TABLE \"cotton_money_accounts\" (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_money_accounts_identity ON cotton_money_accounts (workspace_id, institution, number_mask) WHERE (institution IS NOT NULL) AND (number_mask IS NOT NULL)", "CREATE INDEX idx_cotton_money_accounts_person ON cotton_money_accounts (counterparty_person_id) WHERE counterparty_person_id IS NOT NULL", "CREATE INDEX idx_cotton_money_accounts_workspace ON cotton_money_accounts (workspace_id)", "CREATE UNIQUE INDEX uq_cotton_money_accounts_default ON cotton_money_accounts (workspace_id) WHERE is_default = 1", "CREATE INDEX IF NOT EXISTS idx_cotton_money_accounts_author ON cotton_money_accounts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "months": { "tables": [] }, "mood": { "engine": "mood", "tables": [ { "name": "cotton_moods", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n at TEXT NOT NULL", "position": 2 }, { "name": "line", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n line TEXT", "position": 3 }, { "name": "emotions", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n emotions TEXT NOT NULL DEFAULT '[]'", "position": 4 }, { "name": "emotions_by", "type": "TEXT", "default": "'assistant'", "nullable": false, "primary_key": false, "declaration": "\n emotions_by TEXT NOT NULL DEFAULT 'assistant'", "position": 5 }, { "name": "local_day", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n local_day TEXT NOT NULL", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n CHECK (line IS NULL OR (length(trim(line)) > 0 AND length(line) <= 1000))", "position": 12 }, { "declaration": "\n CHECK (json_type(emotions) = 'array')", "position": 13 }, { "declaration": "\n CHECK (emotions_by IN ('user', 'assistant'))", "position": 14 }, { "declaration": "\n CHECK (local_day GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]')", "position": 15 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 16 } ], "prefix": "CREATE TABLE cotton_moods (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_moods_local_day ON cotton_moods (workspace_id, local_day)", "CREATE INDEX idx_cotton_moods_at ON cotton_moods (workspace_id, at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_moods_author ON cotton_moods (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_moods USING fts5(\n line, content = 'cotton_moods', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_moods_ai AFTER INSERT ON cotton_moods WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_moods'), 0) BEGIN\n INSERT INTO fts_moods (rowid, line) VALUES (new.rowid, new.line);\n END", "CREATE TRIGGER fts_moods_ad AFTER DELETE ON cotton_moods WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_moods'), 0) BEGIN\n INSERT INTO fts_moods (fts_moods, rowid, line) VALUES ('delete', old.rowid, old.line);\n END", "CREATE TRIGGER fts_moods_au AFTER UPDATE OF line ON cotton_moods\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_moods'), 0) AND (new.line IS NOT old.line) BEGIN\n INSERT INTO fts_moods (fts_moods, rowid, line) VALUES ('delete', old.rowid, old.line);\n INSERT INTO fts_moods (rowid, line) VALUES (new.rowid, new.line);\n END" ] } ] }, "news_edition": { "engine": "news", "tables": [ { "name": "cotton_news_editions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "status", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'queued'", "position": 2 }, { "name": "trigger_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n trigger_kind TEXT NOT NULL", "position": 3 }, { "name": "edition_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n edition_label TEXT", "position": 4 }, { "name": "covered_from", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n covered_from TEXT NOT NULL", "position": 5 }, { "name": "covered_to", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n covered_to TEXT", "position": 6 }, { "name": "story_count", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n story_count INTEGER", "position": 7 }, { "name": "read_minutes", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_minutes INTEGER", "position": 8 }, { "name": "quiet", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n quiet TEXT NOT NULL DEFAULT '[]'", "position": 9 }, { "name": "notes", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n notes TEXT NOT NULL DEFAULT '[]'", "position": 10 }, { "name": "model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n model TEXT", "position": 11 }, { "name": "opened_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n opened_at TEXT", "position": 12 }, { "name": "status_changed_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n status_changed_at TEXT NOT NULL", "position": 13 }, { "name": "failed_stage", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n failed_stage TEXT", "position": 14 }, { "name": "error_code", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error_code TEXT", "position": 15 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 16 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 17 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 18 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 19 } ], "constraints": [ { "declaration": "\n CHECK ((status = 'failed') = (failed_stage IS NOT NULL))", "position": 20 }, { "declaration": "\n CHECK (failed_stage IS NULL OR failed_stage IN ('harvest', 'write'))", "position": 21 }, { "declaration": "\n CHECK ((read_minutes IS NULL) OR (read_minutes >= 0))", "position": 22 }, { "declaration": "\n CHECK (status IN ('queued', 'harvesting', 'writing', 'ready', 'failed'))", "position": 23 }, { "declaration": "\n CHECK ((story_count IS NULL) OR (story_count >= 0))", "position": 24 }, { "declaration": "\n CHECK (trigger_kind IN ('scheduled', 'manual', 'stale_open'))", "position": 25 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 26 } ], "prefix": "CREATE TABLE cotton_news_editions (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_news_editions_pipeline ON cotton_news_editions (status, status_changed_at) WHERE status IN ('queued', 'harvesting', 'writing')", "CREATE INDEX idx_cotton_news_editions_workspace_created ON cotton_news_editions (workspace_id, created_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_news_editions_author ON cotton_news_editions (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "news_settings": { "engine": "news", "tables": [ { "name": "cotton_news_settings", "columns": [ { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n workspace_id TEXT PRIMARY KEY", "position": 0 }, { "name": "edition_times", "type": "TEXT", "default": "'[\"07:00\", \"19:00\"]'", "nullable": false, "primary_key": false, "declaration": "\n edition_times TEXT NOT NULL DEFAULT '[\"07:00\", \"19:00\"]'", "position": 1 }, { "name": "timezone", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n timezone TEXT NOT NULL", "position": 2 }, { "name": "stale_after_minutes", "type": "INTEGER", "default": "360", "nullable": false, "primary_key": false, "declaration": "\n stale_after_minutes INTEGER NOT NULL DEFAULT 360", "position": 3 }, { "name": "stale_refresh", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n stale_refresh INTEGER NOT NULL DEFAULT 1", "position": 4 }, { "name": "notify", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n notify INTEGER NOT NULL DEFAULT 1", "position": 5 }, { "name": "next_edition_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n next_edition_at TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n CHECK (json_type(edition_times) = 'array')", "position": 11 }, { "declaration": "\n CHECK (stale_after_minutes > 0)", "position": 12 }, { "declaration": "\n CHECK (length(trim(timezone)) > 0)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE cotton_news_settings (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_news_settings_author ON cotton_news_settings (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "news_story": { "engine": "news", "tables": [ { "name": "cotton_news_stories", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "edition_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n edition_id TEXT NOT NULL", "position": 1 }, { "name": "topic_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n topic_id TEXT", "position": 2 }, { "name": "rank", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n rank INTEGER NOT NULL", "position": 3 }, { "name": "headline", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n headline TEXT NOT NULL", "position": 4 }, { "name": "lede", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n lede TEXT NOT NULL", "position": 5 }, { "name": "bullets", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n bullets TEXT NOT NULL DEFAULT '[]'", "position": 6 }, { "name": "sources", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n sources TEXT NOT NULL DEFAULT '[]'", "position": 7 }, { "name": "why_care", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n why_care TEXT", "position": 8 }, { "name": "read_minutes", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_minutes INTEGER", "position": 9 }, { "name": "opened_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n opened_at TEXT", "position": 10 }, { "name": "feedback", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n feedback TEXT", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n CHECK (feedback IS NULL OR feedback IN ('less', 'more'))", "position": 15 }, { "declaration": "\n CHECK (rank >= 0)", "position": 16 }, { "declaration": "\n CHECK ((read_minutes IS NULL) OR (read_minutes >= 0))", "position": 17 }, { "declaration": "\n FOREIGN KEY (edition_id) REFERENCES cotton_news_editions(id)\n ", "position": 18 } ], "prefix": "CREATE TABLE cotton_news_stories (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_news_stories_edition_rank ON cotton_news_stories (edition_id, rank)", "CREATE INDEX IF NOT EXISTS idx_cotton_news_stories_author ON cotton_news_stories (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_news_seen", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "topic_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n topic_id TEXT NOT NULL", "position": 2 }, { "name": "key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n \"key\" TEXT NOT NULL", "position": 3 }, { "name": "title_hash", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title_hash TEXT", "position": 4 }, { "name": "url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n url TEXT", "position": 5 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 6 }, { "name": "first_seen_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n first_seen_at TEXT NOT NULL", "position": 7 }, { "name": "story_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n story_id TEXT", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, \"key\")", "position": 11 }, { "declaration": "\n CHECK (source IN ('google_news', 'hn', 'brave', 'rss'))", "position": 12 }, { "declaration": "\n FOREIGN KEY (topic_id) REFERENCES cotton_news_topics(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE cotton_news_seen (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_news_seen_topic ON cotton_news_seen (workspace_id, topic_id, first_seen_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_news_seen_author ON cotton_news_seen (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "news_topic": { "engine": "news", "tables": [ { "name": "cotton_news_topics", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 2 }, { "name": "brief", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n brief TEXT NOT NULL DEFAULT ''", "position": 3 }, { "name": "exclusions", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n exclusions TEXT NOT NULL DEFAULT ''", "position": 4 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 5 }, { "name": "source_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_url TEXT", "position": 6 }, { "name": "active", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n active INTEGER NOT NULL DEFAULT 1", "position": 7 }, { "name": "paused_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n paused_reason TEXT", "position": 8 }, { "name": "unopened_streak", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n unopened_streak INTEGER NOT NULL DEFAULT 0", "position": 9 }, { "name": "last_new_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_new_at TEXT", "position": 10 }, { "name": "sort_order", "type": "REAL", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sort_order REAL NOT NULL DEFAULT 0", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 13 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 14 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 15 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 16 } ], "constraints": [ { "declaration": "\n CHECK (kind IN ('search', 'source'))", "position": 17 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 18 }, { "declaration": "\n CHECK (paused_reason IS NULL OR paused_reason IN ('user', 'auto'))", "position": 19 }, { "declaration": "\n CHECK ((source_url IS NULL) OR (kind = 'source'))", "position": 20 }, { "declaration": "\n CHECK (unopened_streak >= 0)", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 22 } ], "prefix": "CREATE TABLE cotton_news_topics (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_news_topics_workspace_active ON cotton_news_topics (workspace_id, active, sort_order)", "CREATE INDEX IF NOT EXISTS idx_cotton_news_topics_author ON cotton_news_topics (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "note": { "engine": "notes", "tables": [ { "name": "cotton_notes", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "kind", "type": "TEXT", "default": "'note'", "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL DEFAULT 'note'", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 2 }, { "name": "body", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL DEFAULT ''", "position": 3 }, { "name": "journal_date", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n journal_date TEXT", "position": 4 }, { "name": "project_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n project_id TEXT", "position": 5 }, { "name": "published_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n published_at TEXT", "position": 6 }, { "name": "public_slug", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n public_slug TEXT", "position": 7 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 11 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 12 }, { "name": "author_kind", "type": "TEXT", "default": "'user'", "nullable": false, "primary_key": false, "declaration": "\n author_kind TEXT NOT NULL DEFAULT 'user'", "position": 13 }, { "name": "author_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_label TEXT", "position": 14 }, { "name": "managed_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n managed_by TEXT", "position": 15 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_id TEXT", "position": 16 }, { "name": "source_hash", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_hash TEXT", "position": 17 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 18 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 19 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 20 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 21 }, { "name": "pinned", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n pinned INTEGER NOT NULL DEFAULT 0 CHECK (pinned IN (0, 1))", "position": 22 } ], "constraints": [ { "declaration": "\n CHECK (author_kind IN ('user', 'agent'))", "position": 23 }, { "declaration": "\n CHECK ((author_kind = 'agent') = (author_label IS NOT NULL))", "position": 24 }, { "declaration": "\n CHECK (kind IN ('note', 'journal'))", "position": 25 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 26 } ], "prefix": "CREATE TABLE cotton_notes (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_notes_home ON cotton_notes (workspace_id) WHERE kind = 'note' AND managed_by IS NULL AND archived_at IS NULL AND trashed_at IS NULL", "CREATE INDEX idx_cotton_notes_managed ON cotton_notes (managed_by) WHERE managed_by IS NOT NULL", "CREATE INDEX idx_cotton_notes_workspace ON cotton_notes (workspace_id)", "CREATE UNIQUE INDEX idx_cotton_notes_workspace_external ON cotton_notes (workspace_id, external_id) WHERE external_id IS NOT NULL", "CREATE UNIQUE INDEX uq_cotton_notes_public_slug ON cotton_notes (public_slug) WHERE public_slug IS NOT NULL", "CREATE UNIQUE INDEX uq_cotton_notes_journal_day ON cotton_notes (workspace_id, journal_date, COALESCE(project_id, '')) WHERE kind = 'journal'", "CREATE INDEX idx_cotton_notes_origin ON cotton_notes (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_notes_author ON cotton_notes (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_notes USING fts5(\n title, body, content = 'cotton_notes', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_notes_ai AFTER INSERT ON cotton_notes WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_notes'), 0) BEGIN\n INSERT INTO fts_notes (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END", "CREATE TRIGGER fts_notes_ad AFTER DELETE ON cotton_notes WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_notes'), 0) BEGIN\n INSERT INTO fts_notes (fts_notes, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n END", "CREATE TRIGGER fts_notes_au AFTER UPDATE OF title, body ON cotton_notes\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_notes'), 0) AND (new.title IS NOT old.title OR new.body IS NOT old.body) BEGIN\n INSERT INTO fts_notes (fts_notes, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n INSERT INTO fts_notes (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END" ] }, { "name": "cotton_note_attachments", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "note_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n note_id TEXT NOT NULL", "position": 2 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 3 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 4 }, { "name": "position", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n position INTEGER NOT NULL", "position": 5 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n UNIQUE (note_id, record_kind, record_id)", "position": 12 }, { "declaration": "\n CHECK (record_kind IN ('photo', 'video', 'document'))", "position": 13 }, { "declaration": "\n CHECK (length(record_id) > 0)", "position": 14 }, { "declaration": "\n CHECK (position >= 0)", "position": 15 }, { "declaration": "\n CHECK (caption IS NULL OR length(caption) <= 500)", "position": 16 }, { "declaration": "\n FOREIGN KEY (note_id) REFERENCES cotton_notes(id)", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 18 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_note_attachments (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_note_attachments_author ON cotton_note_attachments (substr(_hlc, 20), _hlc)", "CREATE INDEX IF NOT EXISTS idx_cotton_note_attachments_note ON cotton_note_attachments (note_id, position)" ], "full_text": [], "triggers": [] } ] }, "order": { "tables": [] }, "order_item": { "tables": [] }, "outage": { "engine": "outages", "tables": [ { "name": "cotton_outages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL CHECK (length(trim(kind)) > 0)", "position": 2 }, { "name": "condition", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n condition TEXT NOT NULL CHECK (length(trim(condition)) > 0)", "position": 3 }, { "name": "machine", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n machine TEXT", "position": 4 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL CHECK (length(trim(title)) > 0)", "position": 5 }, { "name": "effect", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n effect TEXT NOT NULL CHECK (length(trim(effect)) > 0)", "position": 6 }, { "name": "doing", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n doing TEXT NOT NULL CHECK (length(trim(doing)) > 0)", "position": 7 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n started_at TEXT NOT NULL", "position": 8 }, { "name": "ended_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ended_at TEXT", "position": 9 }, { "name": "told_open_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n told_open_at TEXT", "position": 10 }, { "name": "told_close_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n told_close_at TEXT", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 13 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 14 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 15 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 16 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_outages (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_outages_author ON cotton_outages (substr(_hlc, 20), _hlc)", "CREATE INDEX idx_cotton_outages_open ON cotton_outages (workspace_id, condition) WHERE ended_at IS NULL", "CREATE INDEX idx_cotton_outages_started ON cotton_outages (workspace_id, started_at DESC)" ], "full_text": [], "triggers": [] } ] }, "owed": { "tables": [] }, "page": { "engine": "reader", "tables": [ { "name": "cotton_pages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "url", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n url TEXT NOT NULL", "position": 2 }, { "name": "host", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n host TEXT NOT NULL", "position": 3 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 4 }, { "name": "read_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_at TEXT", "position": 5 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 9 }, { "name": "text_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n text_state TEXT CHECK (text_state IS NULL OR text_state IN ('kept', 'unreachable', 'unreadable'))", "position": 10 }, { "name": "state", "type": "TEXT", "default": "'unread'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'unread' CHECK (state IN ('unread', 'reading', 'read'))", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 }, { "name": "text", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n text TEXT", "position": 14 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 15 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 16 } ], "prefix": "CREATE TABLE cotton_pages (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_pages_workspace ON cotton_pages (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_pages_author ON cotton_pages (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_pages USING fts5(\n title, text, content = 'cotton_pages', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_pages_ai AFTER INSERT ON cotton_pages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) BEGIN\n INSERT INTO fts_pages (rowid, title, text) VALUES (new.rowid, new.title, new.text);\n END", "CREATE TRIGGER fts_pages_ad AFTER DELETE ON cotton_pages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) BEGIN\n INSERT INTO fts_pages (fts_pages, rowid, title, text) VALUES ('delete', old.rowid, old.title, old.text);\n END", "CREATE TRIGGER fts_pages_au AFTER UPDATE OF title, text ON cotton_pages\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_pages'), 0) AND (new.title IS NOT old.title OR new.text IS NOT old.text) BEGIN\n INSERT INTO fts_pages (fts_pages, rowid, title, text) VALUES ('delete', old.rowid, old.title, old.text);\n INSERT INTO fts_pages (rowid, title, text) VALUES (new.rowid, new.title, new.text);\n END" ] } ] }, "person": { "engine": "people", "tables": [ { "name": "cotton_people", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "full_name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n full_name TEXT NOT NULL", "position": 2 }, { "name": "org", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n org TEXT", "position": 3 }, { "name": "role_title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n role_title TEXT", "position": 4 }, { "name": "city", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n city TEXT", "position": 5 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 6 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_updated_at TEXT", "position": 7 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 8 }, { "name": "contact_source", "type": "TEXT", "default": "'manual'", "nullable": false, "primary_key": false, "declaration": "\n contact_source TEXT NOT NULL DEFAULT 'manual'", "position": 9 }, { "name": "device_contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n device_contact_id TEXT", "position": 10 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 11 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 12 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 13 }, { "name": "birth_month", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n birth_month INTEGER", "position": 14 }, { "name": "birth_day", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n birth_day INTEGER", "position": 15 }, { "name": "birth_year", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n birth_year INTEGER", "position": 16 }, { "name": "timezone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n timezone TEXT", "position": 17 }, { "name": "avatar_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_url TEXT", "position": 18 }, { "name": "avatar_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_key TEXT", "position": 19 }, { "name": "device_contact_snapshot", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n device_contact_snapshot TEXT", "position": 20 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 21 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 22 }, { "name": "city_filled_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n city_filled_at TEXT", "position": 23 }, { "name": "avatar_photo_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_photo_id TEXT", "position": 24 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 25 }, { "name": "language", "type": "TEXT", "default": "'en'", "nullable": false, "primary_key": false, "declaration": " language TEXT NOT NULL DEFAULT 'en' CHECK (length(language) BETWEEN 2 AND 3 AND language NOT GLOB '*[^a-z]*')", "position": 26 }, { "name": "face_embedding", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " face_embedding TEXT CHECK (face_embedding IS NULL OR length(face_embedding) > 0)", "position": 27 }, { "name": "face_embedding_model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " face_embedding_model TEXT CHECK (face_embedding_model IS NULL OR length(face_embedding_model) > 0)", "position": 28 }, { "name": "face_embedding_from", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " face_embedding_from TEXT CHECK (face_embedding_from IS NULL OR length(face_embedding_from) > 0)", "position": 29 }, { "name": "city_place", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " city_place TEXT", "position": 30 }, { "name": "country", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " country TEXT", "position": 31 } ], "constraints": [ { "declaration": "\n CHECK ((birth_day IS NULL) OR ((birth_day >= 1) AND (birth_day <= 31)))", "position": 32 }, { "declaration": "\n CHECK ((birth_month IS NULL) OR ((birth_month >= 1) AND (birth_month <= 12)))", "position": 33 }, { "declaration": "\n CHECK (((birth_month IS NOT NULL) + (birth_day IS NOT NULL)) IN (0, 2))", "position": 34 }, { "declaration": "\n CHECK (contact_source IN ('import', 'manual', 'apple_library'))", "position": 35 }, { "declaration": "\n CHECK ((summary IS NULL) OR (length(summary) <= 4000))", "position": 36 }, { "declaration": "\n CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 37 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 38 } ], "prefix": "CREATE TABLE \"cotton_people\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_people_workspace ON cotton_people (workspace_id)", "CREATE UNIQUE INDEX uq_cotton_people_device_contact ON cotton_people (workspace_id, device_contact_id) WHERE device_contact_id IS NOT NULL", "CREATE INDEX idx_cotton_people_city_filled ON cotton_people (workspace_id, city_filled_at) WHERE city_filled_at IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_people_author ON cotton_people (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_people USING fts5(\n full_name, org, role_title, summary, content = 'cotton_people', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_people_ai AFTER INSERT ON cotton_people WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_people'), 0) BEGIN\n INSERT INTO fts_people (rowid, full_name, org, role_title, summary) VALUES (new.rowid, new.full_name, new.org, new.role_title, new.summary);\n END", "CREATE TRIGGER fts_people_ad AFTER DELETE ON cotton_people WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_people'), 0) BEGIN\n INSERT INTO fts_people (fts_people, rowid, full_name, org, role_title, summary) VALUES ('delete', old.rowid, old.full_name, old.org, old.role_title, old.summary);\n END", "CREATE TRIGGER fts_people_au AFTER UPDATE OF full_name, org, role_title, summary ON cotton_people\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_people'), 0) AND (new.full_name IS NOT old.full_name OR new.org IS NOT old.org OR new.role_title IS NOT old.role_title OR new.summary IS NOT old.summary) BEGIN\n INSERT INTO fts_people (fts_people, rowid, full_name, org, role_title, summary) VALUES ('delete', old.rowid, old.full_name, old.org, old.role_title, old.summary);\n INSERT INTO fts_people (rowid, full_name, org, role_title, summary) VALUES (new.rowid, new.full_name, new.org, new.role_title, new.summary);\n END" ] } ] }, "person_handle": { "engine": "people", "tables": [ { "name": "cotton_person_handles", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n person_id TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL CHECK (kind IN ('phone','email','instagram','facebook','linkedin'))", "position": 3 }, { "name": "value", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n value TEXT NOT NULL CHECK (length(trim(value)) > 0)", "position": 4 }, { "name": "normalised", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n normalised TEXT NOT NULL CHECK (length(normalised) > 0)", "position": 5 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL CHECK (source IN ('manual','contacts','import','suggestion','whatsapp','instagram','facebook','linkedin'))", "position": 6 }, { "name": "verified_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n verified_at TEXT", "position": 7 }, { "name": "position", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n position INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 13 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (person_id) REFERENCES cotton_people(id)", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_person_handles (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_person_handles_author ON cotton_person_handles (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX uq_cotton_person_handles_handle ON cotton_person_handles (workspace_id, kind, normalised)", "CREATE INDEX idx_cotton_person_handles_person ON cotton_person_handles (person_id)" ], "full_text": [], "triggers": [] } ] }, "person_language": { "engine": "people", "tables": [ { "name": "cotton_person_languages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n person_id TEXT NOT NULL", "position": 2 }, { "name": "language", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n language TEXT NOT NULL CHECK (length(trim(language)) > 0)", "position": 3 }, { "name": "proficiency", "type": "TEXT", "default": "'fluent'", "nullable": false, "primary_key": false, "declaration": "\n proficiency TEXT NOT NULL DEFAULT 'fluent' CHECK (proficiency IN ('native','fluent','conversational','basic'))", "position": 4 }, { "name": "position", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n position INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (person_id) REFERENCES cotton_people(id)", "position": 11 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 12 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_person_languages (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_person_languages_author ON cotton_person_languages (substr(_hlc, 20), _hlc)", "CREATE INDEX idx_cotton_person_languages_person ON cotton_person_languages (person_id)" ], "full_text": [], "triggers": [] } ] }, "person_note": { "engine": "people", "tables": [ { "name": "cotton_person_notes", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n person_id TEXT NOT NULL", "position": 1 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 2 }, { "name": "noted_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n noted_at TEXT NOT NULL", "position": 3 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 4 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (person_id) REFERENCES cotton_people(id)\n ", "position": 8 } ], "prefix": "CREATE TABLE cotton_person_notes (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_person_notes_person ON cotton_person_notes (person_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_person_notes_author ON cotton_person_notes (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "person_suggestion": { "engine": "people", "tables": [ { "name": "cotton_person_suggestions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 2 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n contact_id TEXT", "position": 3 }, { "name": "candidate_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n candidate_id TEXT NOT NULL", "position": 4 }, { "name": "reason", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n reason TEXT NOT NULL", "position": 5 }, { "name": "score", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n score REAL NOT NULL", "position": 6 }, { "name": "state", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'open'", "position": 7 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK (person_id <> candidate_id)", "position": 13 }, { "declaration": "\n CHECK (reason IN ('name_exact', 'name_fuzzy', 'handle_name'))", "position": 14 }, { "declaration": "\n CHECK (score >= 0 AND score <= 1)", "position": 15 }, { "declaration": "\n CHECK (state IN ('open', 'merged', 'different'))", "position": 16 }, { "declaration": "\n CHECK ((state = 'open') = (decided_at IS NULL))", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 18 } ], "prefix": "CREATE TABLE cotton_person_suggestions (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_person_suggestions_pair ON cotton_person_suggestions (workspace_id, person_id, candidate_id)", "CREATE UNIQUE INDEX uq_cotton_person_suggestions_contact ON cotton_person_suggestions (workspace_id, contact_id, candidate_id) WHERE contact_id IS NOT NULL", "CREATE INDEX idx_cotton_person_suggestions_open ON cotton_person_suggestions (workspace_id, person_id) WHERE state = 'open'", "CREATE INDEX idx_cotton_person_suggestions_candidate ON cotton_person_suggestions (workspace_id, candidate_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_person_suggestions_author ON cotton_person_suggestions (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "photo": { "engine": "media", "tables": [ { "name": "cotton_photos", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n key TEXT NOT NULL", "position": 2 }, { "name": "sha256", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha256 TEXT NOT NULL", "position": 3 }, { "name": "content_type", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n content_type TEXT NOT NULL", "position": 4 }, { "name": "size_bytes", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n size_bytes INTEGER NOT NULL", "position": 5 }, { "name": "width", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n width INTEGER", "position": 6 }, { "name": "height", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n height INTEGER", "position": 7 }, { "name": "taken_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n taken_at TEXT NOT NULL", "position": 8 }, { "name": "preview", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n preview TEXT", "position": 9 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 10 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 11 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 12 }, { "name": "summary_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_at TEXT", "position": 13 }, { "name": "review_note", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_note TEXT", "position": 14 }, { "name": "review_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_by TEXT", "position": 15 }, { "name": "review_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_at TEXT", "position": 16 }, { "name": "taken_offset", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n taken_offset INTEGER", "position": 17 }, { "name": "latitude", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n latitude REAL", "position": 18 }, { "name": "longitude", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n longitude REAL", "position": 19 }, { "name": "place_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_name TEXT", "position": 20 }, { "name": "place_city", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_city TEXT", "position": 21 }, { "name": "place_region", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_region TEXT", "position": 22 }, { "name": "place_country", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_country TEXT", "position": 23 }, { "name": "camera_make", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n camera_make TEXT", "position": 24 }, { "name": "camera_model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n camera_model TEXT", "position": 25 }, { "name": "orientation", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n orientation INTEGER", "position": 26 }, { "name": "favourite", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n favourite INTEGER NOT NULL DEFAULT 0", "position": 27 }, { "name": "subtypes", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n subtypes TEXT NOT NULL DEFAULT '[]'", "position": 28 }, { "name": "original_filename", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n original_filename TEXT", "position": 29 }, { "name": "aesthetic_score", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n aesthetic_score REAL", "position": 30 }, { "name": "curation_score", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n curation_score REAL", "position": 31 }, { "name": "labels", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n labels TEXT NOT NULL DEFAULT '[]'", "position": 32 }, { "name": "phash", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n phash TEXT", "position": 33 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 34 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 35 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 36 }, { "name": "ocr_text", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " ocr_text TEXT", "position": 37 }, { "name": "is_utility", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": " is_utility INTEGER CHECK (is_utility IS NULL OR is_utility IN (0, 1))", "position": 38 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 39 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 40 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 41 }, { "name": "image_embedding", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " image_embedding TEXT CHECK (image_embedding IS NULL OR length(image_embedding) > 0)", "position": 42 }, { "name": "image_embedding_model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " image_embedding_model TEXT CHECK (image_embedding_model IS NULL OR length(image_embedding_model) > 0)", "position": 43 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, sha256)", "position": 44 }, { "declaration": "\n CHECK (id = 'photo:' || sha256)", "position": 45 }, { "declaration": "\n CHECK (sha256 NOT GLOB '*[^0-9a-f]*' AND length(sha256) = 64)", "position": 46 }, { "declaration": "\n CHECK (size_bytes >= 0)", "position": 47 }, { "declaration": "\n CHECK (width IS NULL OR width > 0)", "position": 48 }, { "declaration": "\n CHECK (height IS NULL OR height > 0)", "position": 49 }, { "declaration": "\n CHECK (caption IS NULL OR length(caption) <= 500)", "position": 50 }, { "declaration": "\n CHECK (review_note IS NULL OR (length(trim(review_note)) > 0 AND length(review_note) <= 280))", "position": 51 }, { "declaration": "\n CHECK ((summary IS NULL) = (summary_at IS NULL))", "position": 52 }, { "declaration": "\n CHECK ((review_note IS NULL) = (review_at IS NULL))", "position": 53 }, { "declaration": "\n CHECK ((latitude IS NULL) = (longitude IS NULL))", "position": 54 }, { "declaration": "\n CHECK (latitude IS NULL OR (latitude >= -90 AND latitude <= 90))", "position": 55 }, { "declaration": "\n CHECK (longitude IS NULL OR (longitude >= -180 AND longitude <= 180))", "position": 56 }, { "declaration": "\n CHECK (orientation IS NULL OR (orientation >= 1 AND orientation <= 8))", "position": 57 }, { "declaration": "\n CHECK (taken_offset IS NULL OR (taken_offset >= -86400 AND taken_offset <= 86400))", "position": 58 }, { "declaration": "\n CHECK (favourite IN (0, 1))", "position": 59 }, { "declaration": "\n CHECK (json_type(subtypes) = 'array')", "position": 60 }, { "declaration": "\n CHECK (json_type(labels) = 'array')", "position": 61 }, { "declaration": "\n CHECK (aesthetic_score IS NULL OR (aesthetic_score >= -1 AND aesthetic_score <= 1))", "position": 62 }, { "declaration": "\n CHECK (curation_score IS NULL OR (curation_score >= -1 AND curation_score <= 1))", "position": 63 }, { "declaration": "\n CHECK (phash IS NULL OR (length(phash) = 16 AND phash NOT GLOB '*[^0-9a-f]*'))", "position": 64 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 65 } ], "prefix": "CREATE TABLE \"cotton_photos\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_photos_taken ON cotton_photos (workspace_id, taken_at DESC)", "CREATE INDEX idx_cotton_photos_review ON cotton_photos (workspace_id, review_at) WHERE review_note IS NOT NULL", "CREATE INDEX idx_cotton_photos_undescribed ON cotton_photos (workspace_id, taken_at DESC) WHERE summary IS NULL", "CREATE INDEX idx_cotton_photos_place ON cotton_photos (workspace_id, place_city)", "CREATE INDEX idx_cotton_photos_favourite ON cotton_photos (workspace_id, taken_at DESC) WHERE favourite = 1", "CREATE INDEX idx_cotton_photos_phash ON cotton_photos (workspace_id, phash) WHERE phash IS NOT NULL", "CREATE INDEX idx_cotton_photos_utility ON cotton_photos (workspace_id, taken_at DESC) WHERE is_utility = 1", "CREATE INDEX idx_cotton_photos_origin ON cotton_photos (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_photos_author ON cotton_photos (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_photos USING fts5(\n caption, summary, ocr_text, content = 'cotton_photos', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_photos_ai AFTER INSERT ON cotton_photos WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_photos'), 0) BEGIN\n INSERT INTO fts_photos (rowid, caption, summary, ocr_text) VALUES (new.rowid, new.caption, new.summary, new.ocr_text);\n END", "CREATE TRIGGER fts_photos_ad AFTER DELETE ON cotton_photos WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_photos'), 0) BEGIN\n INSERT INTO fts_photos (fts_photos, rowid, caption, summary, ocr_text) VALUES ('delete', old.rowid, old.caption, old.summary, old.ocr_text);\n END", "CREATE TRIGGER fts_photos_au AFTER UPDATE OF caption, summary, ocr_text ON cotton_photos\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_photos'), 0) AND (new.caption IS NOT old.caption OR new.summary IS NOT old.summary OR new.ocr_text IS NOT old.ocr_text) BEGIN\n INSERT INTO fts_photos (fts_photos, rowid, caption, summary, ocr_text) VALUES ('delete', old.rowid, old.caption, old.summary, old.ocr_text);\n INSERT INTO fts_photos (rowid, caption, summary, ocr_text) VALUES (new.rowid, new.caption, new.summary, new.ocr_text);\n END" ] } ] }, "placement_proposal": { "engine": "placements", "tables": [ { "name": "cotton_placement_proposals", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 2 }, { "name": "items", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n items TEXT NOT NULL", "position": 3 }, { "name": "status", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'open'", "position": 4 }, { "name": "decided_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n decided_at TEXT", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n CHECK (length(title) > 0)", "position": 10 }, { "declaration": "\n CHECK (length(items) > 0)", "position": 11 }, { "declaration": "\n CHECK (status IN ('open', 'approved', 'declined'))", "position": 12 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 13 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_placement_proposals (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_placement_proposals_author ON cotton_placement_proposals (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "post": { "engine": "posts", "tables": [ { "name": "cotton_posts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 2 }, { "name": "account", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n account TEXT NOT NULL", "position": 3 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_id TEXT NOT NULL", "position": 4 }, { "name": "saved", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n saved INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "author_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_handle TEXT", "position": 6 }, { "name": "author_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_name TEXT", "position": 7 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 8 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 9 }, { "name": "media", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n media TEXT NOT NULL DEFAULT '[]'", "position": 10 }, { "name": "posted_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n posted_at TEXT", "position": 11 }, { "name": "saved_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n saved_at TEXT", "position": 12 }, { "name": "permalink", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n permalink TEXT", "position": 13 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 14 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 15 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 16 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 17 } ], "constraints": [ { "declaration": "\n CHECK (saved IN (0, 1))", "position": 18 }, { "declaration": "\n CHECK (trim(external_id) <> '')", "position": 19 }, { "declaration": "\n CHECK (json_valid(media) AND json_type(media) = 'array')", "position": 20 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 21 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_posts (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX IF NOT EXISTS uq_cotton_posts_external ON cotton_posts (workspace_id, source, account, external_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_posts_posted ON cotton_posts (workspace_id, saved, posted_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_posts_author ON cotton_posts (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_posts USING fts5(\n caption, author_name, author_handle, content = 'cotton_posts', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_posts_ai AFTER INSERT ON cotton_posts WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) BEGIN\n INSERT INTO fts_posts (rowid, caption, author_name, author_handle) VALUES (new.rowid, new.caption, new.author_name, new.author_handle);\n END", "CREATE TRIGGER fts_posts_ad AFTER DELETE ON cotton_posts WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) BEGIN\n INSERT INTO fts_posts (fts_posts, rowid, caption, author_name, author_handle) VALUES ('delete', old.rowid, old.caption, old.author_name, old.author_handle);\n END", "CREATE TRIGGER fts_posts_au AFTER UPDATE OF caption, author_name, author_handle ON cotton_posts\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) AND (new.caption IS NOT old.caption OR new.author_name IS NOT old.author_name OR new.author_handle IS NOT old.author_handle) BEGIN\n INSERT INTO fts_posts (fts_posts, rowid, caption, author_name, author_handle) VALUES ('delete', old.rowid, old.caption, old.author_name, old.author_handle);\n INSERT INTO fts_posts (rowid, caption, author_name, author_handle) VALUES (new.rowid, new.caption, new.author_name, new.author_handle);\n END" ] } ] }, "project": { "engine": "projects", "tables": [] }, "project_feedback": { "engine": "feedback", "tables": [] }, "project_item": { "engine": "projects", "tables": [] }, "prompt": { "engine": "sessions", "tables": [ { "name": "cotton_prompts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "session_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n session_id TEXT NOT NULL", "position": 2 }, { "name": "project_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n project_id TEXT", "position": 3 }, { "name": "seq", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n seq INTEGER NOT NULL", "position": 4 }, { "name": "ts", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n ts TEXT NOT NULL", "position": 5 }, { "name": "text", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n text TEXT NOT NULL", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "role", "type": "TEXT", "default": "'user'", "nullable": false, "primary_key": false, "declaration": " role TEXT NOT NULL DEFAULT 'user' CHECK (role IN ('user', 'assistant'))", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n UNIQUE (session_id, seq)", "position": 12 }, { "declaration": "\n CHECK (seq >= 0)", "position": 13 }, { "declaration": "\n CHECK ((length(trim(text)) > 0) AND (length(text) <= 8000))", "position": 14 }, { "declaration": "\n FOREIGN KEY (session_id) REFERENCES cotton_sessions(id)", "position": 15 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 16 } ], "prefix": "CREATE TABLE cotton_prompts (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_prompts_workspace ON cotton_prompts (workspace_id)", "CREATE INDEX idx_cotton_prompts_session ON cotton_prompts (workspace_id, session_id, seq)", "CREATE INDEX IF NOT EXISTS idx_cotton_prompts_author ON cotton_prompts (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_prompts USING fts5(\n text, content = 'cotton_prompts', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_prompts_ai AFTER INSERT ON cotton_prompts WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_prompts'), 0) BEGIN\n INSERT INTO fts_prompts (rowid, text) VALUES (new.rowid, new.text);\n END", "CREATE TRIGGER fts_prompts_ad AFTER DELETE ON cotton_prompts WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_prompts'), 0) BEGIN\n INSERT INTO fts_prompts (fts_prompts, rowid, text) VALUES ('delete', old.rowid, old.text);\n END", "CREATE TRIGGER fts_prompts_au AFTER UPDATE OF text ON cotton_prompts\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_prompts'), 0) AND (new.text IS NOT old.text) BEGIN\n INSERT INTO fts_prompts (fts_prompts, rowid, text) VALUES ('delete', old.rowid, old.text);\n INSERT INTO fts_prompts (rowid, text) VALUES (new.rowid, new.text);\n END" ] } ] }, "pull": { "engine": "repos", "tables": [ { "name": "cotton_repo_pulls", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "number", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n number INTEGER NOT NULL", "position": 3 }, { "name": "remote_id", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_id INTEGER", "position": 4 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 5 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 6 }, { "name": "state", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL", "position": 7 }, { "name": "merged", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n merged INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "draft", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n draft INTEGER NOT NULL DEFAULT 0", "position": 9 }, { "name": "author", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author TEXT", "position": 10 }, { "name": "head_ref", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n head_ref TEXT", "position": 11 }, { "name": "head_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n head_sha TEXT", "position": 12 }, { "name": "base_ref", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n base_ref TEXT", "position": 13 }, { "name": "mergeable", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n mergeable INTEGER", "position": 14 }, { "name": "additions", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n additions INTEGER", "position": 15 }, { "name": "deletions", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n deletions INTEGER", "position": 16 }, { "name": "changed_files", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n changed_files INTEGER", "position": 17 }, { "name": "comments_count", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n comments_count INTEGER", "position": 18 }, { "name": "review_comments_count", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_comments_count INTEGER", "position": 19 }, { "name": "labels", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n labels TEXT NOT NULL DEFAULT '[]'", "position": 20 }, { "name": "checks_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n checks_state TEXT", "position": 21 }, { "name": "checks", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n checks TEXT NOT NULL DEFAULT '[]'", "position": 22 }, { "name": "html_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n html_url TEXT", "position": 23 }, { "name": "remote_created_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_created_at TEXT", "position": 24 }, { "name": "remote_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_updated_at TEXT", "position": 25 }, { "name": "merged_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n merged_at TEXT", "position": 26 }, { "name": "closed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n closed_at TEXT", "position": 27 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 28 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 29 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 30 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 31 }, { "name": "merge_commit_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n merge_commit_sha TEXT", "position": 32 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, number)", "position": 33 }, { "declaration": "\n CHECK (state IN ('open', 'closed'))", "position": 34 }, { "declaration": "\n CHECK (merged IN (0, 1))", "position": 35 }, { "declaration": "\n CHECK (draft IN (0, 1))", "position": 36 }, { "declaration": "\n CHECK (mergeable IS NULL OR mergeable IN (0, 1))", "position": 37 }, { "declaration": "\n CHECK (checks_state IS NULL OR checks_state IN ('pending', 'success', 'failure', 'error', 'warning'))", "position": 38 }, { "declaration": "\n CHECK (json_type(labels) = 'array')", "position": 39 }, { "declaration": "\n CHECK (json_type(checks) = 'array')", "position": 40 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 41 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 42 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_pulls (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_pulls_repo ON cotton_repo_pulls (workspace_id, repo_id, state, remote_updated_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_pulls_author ON cotton_repo_pulls (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_repo_pulls USING fts5(\n title, body, content = 'cotton_repo_pulls', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_repo_pulls_ai AFTER INSERT ON cotton_repo_pulls WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) BEGIN\n INSERT INTO fts_repo_pulls (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END", "CREATE TRIGGER fts_repo_pulls_ad AFTER DELETE ON cotton_repo_pulls WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) BEGIN\n INSERT INTO fts_repo_pulls (fts_repo_pulls, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n END", "CREATE TRIGGER fts_repo_pulls_au AFTER UPDATE OF title, body ON cotton_repo_pulls\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) AND (new.title IS NOT old.title OR new.body IS NOT old.body) BEGIN\n INSERT INTO fts_repo_pulls (fts_repo_pulls, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n INSERT INTO fts_repo_pulls (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n END" ] } ] }, "record_version": { "engine": "history", "tables": [] }, "release": { "engine": "repos", "tables": [ { "name": "cotton_repo_releases", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "tag", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n tag TEXT NOT NULL", "position": 3 }, { "name": "name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n name TEXT", "position": 4 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 5 }, { "name": "draft", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n draft INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "prerelease", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n prerelease INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "target_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n target_sha TEXT", "position": 8 }, { "name": "author", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author TEXT", "position": 9 }, { "name": "published_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n published_at TEXT", "position": 10 }, { "name": "assets_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n assets_json TEXT NOT NULL DEFAULT '[]'", "position": 11 }, { "name": "html_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n html_url TEXT", "position": 12 }, { "name": "remote_id", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_id INTEGER", "position": 13 }, { "name": "synced_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n synced_at TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, tag)", "position": 19 }, { "declaration": "\n CHECK (draft IN (0, 1))", "position": 20 }, { "declaration": "\n CHECK (prerelease IN (0, 1))", "position": 21 }, { "declaration": "\n CHECK (length(trim(tag)) > 0)", "position": 22 }, { "declaration": "\n CHECK (json_type(assets_json) = 'array')", "position": 23 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 24 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 25 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_releases (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_releases_repo ON cotton_repo_releases (workspace_id, repo_id, published_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_releases_author ON cotton_repo_releases (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "repo_comment": { "engine": "repos", "tables": [ { "name": "cotton_repo_comments", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "target_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n target_kind TEXT NOT NULL", "position": 3 }, { "name": "target_number", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n target_number INTEGER NOT NULL", "position": 4 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 5 }, { "name": "remote_id", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n remote_id INTEGER NOT NULL", "position": 6 }, { "name": "author", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author TEXT", "position": 7 }, { "name": "body", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n body TEXT", "position": 8 }, { "name": "review_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_state TEXT", "position": 9 }, { "name": "path", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n path TEXT", "position": 10 }, { "name": "line", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n line INTEGER", "position": 11 }, { "name": "html_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n html_url TEXT", "position": 12 }, { "name": "remote_created_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_created_at TEXT", "position": 13 }, { "name": "remote_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_updated_at TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, kind, remote_id)", "position": 19 }, { "declaration": "\n CHECK (target_kind IN ('pull', 'issue'))", "position": 20 }, { "declaration": "\n CHECK (kind IN ('comment', 'review', 'review_comment'))", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 22 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 23 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_comments (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_comments_target ON cotton_repo_comments (workspace_id, repo_id, target_kind, target_number, remote_created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_comments_author ON cotton_repo_comments (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "repo_file": { "engine": "repos", "tables": [] }, "repo_label": { "engine": "repos", "tables": [ { "name": "cotton_repo_labels", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 3 }, { "name": "color", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n color TEXT", "position": 4 }, { "name": "description", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n description TEXT", "position": 5 }, { "name": "remote_id", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n remote_id INTEGER", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, name)", "position": 11 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 12 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 13 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_labels (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_labels_repo ON cotton_repo_labels (workspace_id, repo_id, name)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_labels_author ON cotton_repo_labels (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "repo_rule": { "engine": "repos", "tables": [ { "name": "cotton_repo_rules", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "branch", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n branch TEXT NOT NULL", "position": 3 }, { "name": "required_contexts_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n required_contexts_json TEXT NOT NULL DEFAULT '[]'", "position": 4 }, { "name": "required_approvals", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n required_approvals INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "block_outdated", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n block_outdated INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "allow_push", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n allow_push INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, branch)", "position": 12 }, { "declaration": "\n CHECK (length(trim(branch)) > 0)", "position": 13 }, { "declaration": "\n CHECK (json_type(required_contexts_json) = 'array')", "position": 14 }, { "declaration": "\n CHECK (required_approvals >= 0)", "position": 15 }, { "declaration": "\n CHECK (block_outdated IN (0, 1))", "position": 16 }, { "declaration": "\n CHECK (allow_push IN (0, 1))", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 18 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 19 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_rules (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_rules_repo ON cotton_repo_rules (workspace_id, repo_id, branch)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_rules_author ON cotton_repo_rules (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "repo_var": { "engine": "ci", "tables": [ { "name": "cotton_repo_vars", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 3 }, { "name": "value", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n value TEXT NOT NULL", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, name)", "position": 9 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 10 }, { "declaration": "\n CHECK (name NOT GLOB '*[^A-Za-z0-9_]*')", "position": 11 }, { "declaration": "\n CHECK (length(value) <= 65536)", "position": 12 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 13 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_vars (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_vars_repo ON cotton_repo_vars (workspace_id, repo_id, name)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_vars_author ON cotton_repo_vars (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "repository": { "engine": "repos", "tables": [ { "name": "cotton_repos", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n key TEXT NOT NULL", "position": 2 }, { "name": "host", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n host TEXT NOT NULL", "position": 3 }, { "name": "owner", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n owner TEXT NOT NULL", "position": 4 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 5 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 6 }, { "name": "default_branch", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n default_branch TEXT", "position": 7 }, { "name": "description", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n description TEXT", "position": 8 }, { "name": "web_url", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n web_url TEXT NOT NULL", "position": 9 }, { "name": "open_pulls", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n open_pulls INTEGER", "position": 10 }, { "name": "open_issues", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n open_issues INTEGER", "position": 11 }, { "name": "sync_state", "type": "TEXT", "default": "'pending'", "nullable": false, "primary_key": false, "declaration": "\n sync_state TEXT NOT NULL DEFAULT 'pending'", "position": 12 }, { "name": "last_error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_error TEXT", "position": 13 }, { "name": "synced_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n synced_at TEXT", "position": 14 }, { "name": "pulls_cursor", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n pulls_cursor TEXT", "position": 15 }, { "name": "issues_cursor", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n issues_cursor TEXT", "position": 16 }, { "name": "held", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n held INTEGER NOT NULL DEFAULT 0", "position": 17 }, { "name": "origin", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n origin TEXT", "position": 18 }, { "name": "head_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n head_sha TEXT", "position": 19 }, { "name": "held_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n held_at TEXT", "position": 20 }, { "name": "bundle_state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n bundle_state TEXT", "position": 21 }, { "name": "last_bundle_error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_bundle_error TEXT", "position": 22 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 23 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 24 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 25 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 26 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, key)", "position": 27 }, { "declaration": "\n CHECK (kind IN ('github', 'forgejo', 'cotton'))", "position": 28 }, { "declaration": "\n CHECK (sync_state IN ('pending', 'ok', 'no_token', 'error', 'unsupported', 'held'))", "position": 29 }, { "declaration": "\n CHECK (held IN (0, 1))", "position": 30 }, { "declaration": "\n CHECK (origin IS NULL OR origin IN ('forgejo', 'github', 'cotton'))", "position": 31 }, { "declaration": "\n CHECK (bundle_state IS NULL OR bundle_state IN ('none', 'bundling', 'ok', 'error'))", "position": 32 }, { "declaration": "\n CHECK (length(trim(key)) > 0)", "position": 33 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 34 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repos (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repos_author ON cotton_repos (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_commits", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "sha", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha TEXT NOT NULL", "position": 3 }, { "name": "message", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n message TEXT NOT NULL", "position": 4 }, { "name": "author_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_name TEXT", "position": 5 }, { "name": "author_login", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_login TEXT", "position": 6 }, { "name": "authored_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n authored_at TEXT", "position": 7 }, { "name": "parents", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n parents TEXT NOT NULL DEFAULT '[]'", "position": 8 }, { "name": "html_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n html_url TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, sha)", "position": 14 }, { "declaration": "\n CHECK (json_type(parents) = 'array')", "position": 15 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 16 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 17 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_commits (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_commits_repo ON cotton_repo_commits (workspace_id, repo_id, authored_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_commits_author ON cotton_repo_commits (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_bundles", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "object_key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n object_key TEXT NOT NULL", "position": 3 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 4 }, { "name": "basis_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n basis_sha TEXT", "position": 5 }, { "name": "head_sha", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n head_sha TEXT NOT NULL", "position": 6 }, { "name": "refs_json", "type": "TEXT", "default": "'{}'", "nullable": false, "primary_key": false, "declaration": "\n refs_json TEXT NOT NULL DEFAULT '{}'", "position": 7 }, { "name": "bytes", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n bytes INTEGER NOT NULL", "position": 8 }, { "name": "sha256", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha256 TEXT NOT NULL", "position": 9 }, { "name": "superseded_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n superseded_at TEXT", "position": 10 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 11 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 12 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, sha256)", "position": 15 }, { "declaration": "\n CHECK (kind IN ('full', 'incremental'))", "position": 16 }, { "declaration": "\n CHECK ((kind = 'full') = (basis_sha IS NULL))", "position": 17 }, { "declaration": "\n CHECK (bytes >= 0)", "position": 18 }, { "declaration": "\n CHECK (length(sha256) = 64)", "position": 19 }, { "declaration": "\n CHECK (length(trim(object_key)) > 0)", "position": 20 }, { "declaration": "\n CHECK (json_type(refs_json) = 'object')", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 22 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 23 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_bundles (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_bundles_repo ON cotton_repo_bundles (workspace_id, repo_id, created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_bundles_author ON cotton_repo_bundles (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_clones", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n device_id TEXT NOT NULL", "position": 3 }, { "name": "state", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL", "position": 4 }, { "name": "sentence", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sentence TEXT", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, device_id)", "position": 10 }, { "declaration": "\n CHECK (state IN ('ok', 'forked'))", "position": 11 }, { "declaration": "\n CHECK (length(trim(device_id)) > 0)", "position": 12 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 13 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_clones (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_clones_repo ON cotton_repo_clones (workspace_id, repo_id, state)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_clones_author ON cotton_repo_clones (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_runners", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n repo_id TEXT", "position": 2 }, { "name": "uuid", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n uuid TEXT NOT NULL", "position": 3 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 4 }, { "name": "labels_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n labels_json TEXT NOT NULL DEFAULT '[]'", "position": 5 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n device_id TEXT", "position": 6 }, { "name": "credential_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n credential_id TEXT NOT NULL", "position": 7 }, { "name": "version", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n version TEXT", "position": 8 }, { "name": "last_seen_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_seen_at TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, uuid)", "position": 14 }, { "declaration": "\n CHECK (length(trim(uuid)) > 0)", "position": 15 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 16 }, { "declaration": "\n CHECK (length(trim(credential_id)) > 0)", "position": 17 }, { "declaration": "\n CHECK (json_type(labels_json) = 'array')", "position": 18 }, { "declaration": "\n CHECK (repo_id IS NULL OR length(repo_id) > 0)", "position": 19 }, { "declaration": "\n CHECK (device_id IS NULL OR length(device_id) > 0)", "position": 20 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 21 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 22 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_runners (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runners_workspace ON cotton_repo_runners (workspace_id, last_seen_at DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runners_author ON cotton_repo_runners (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_jobs", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "run_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n run_id TEXT NOT NULL", "position": 2 }, { "name": "index_in_run", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n index_in_run INTEGER NOT NULL", "position": 3 }, { "name": "task_id", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n task_id INTEGER NOT NULL", "position": 4 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 5 }, { "name": "runs_on", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n runs_on TEXT NOT NULL", "position": 6 }, { "name": "needs_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n needs_json TEXT NOT NULL DEFAULT '[]'", "position": 7 }, { "name": "status", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'queued'", "position": 8 }, { "name": "conclusion", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n conclusion TEXT", "position": 9 }, { "name": "runner_uuid", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n runner_uuid TEXT", "position": 10 }, { "name": "timeout_minutes", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n timeout_minutes INTEGER", "position": 11 }, { "name": "outputs_json", "type": "TEXT", "default": "'{}'", "nullable": false, "primary_key": false, "declaration": "\n outputs_json TEXT NOT NULL DEFAULT '{}'", "position": 12 }, { "name": "steps_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n steps_json TEXT NOT NULL DEFAULT '[]'", "position": 13 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 14 }, { "name": "log_lines", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n log_lines INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "log_ack", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n log_ack INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "log_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n log_key TEXT", "position": 17 }, { "name": "cancel_requested", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n cancel_requested INTEGER NOT NULL DEFAULT 0", "position": 18 }, { "name": "requeues", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n requeues INTEGER NOT NULL DEFAULT 0", "position": 19 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n started_at TEXT", "position": 20 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 21 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 22 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 23 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 24 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 25 }, { "name": "token_digest", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n token_digest TEXT", "position": 26 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, run_id, index_in_run)", "position": 27 }, { "declaration": "\n UNIQUE (workspace_id, task_id)", "position": 28 }, { "declaration": "\n CHECK (index_in_run > 0)", "position": 29 }, { "declaration": "\n CHECK (task_id > 0)", "position": 30 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 31 }, { "declaration": "\n CHECK (length(trim(runs_on)) > 0)", "position": 32 }, { "declaration": "\n CHECK (json_type(needs_json) = 'array')", "position": 33 }, { "declaration": "\n CHECK (json_type(outputs_json) = 'object')", "position": 34 }, { "declaration": "\n CHECK (json_type(steps_json) = 'array')", "position": 35 }, { "declaration": "\n CHECK (status IN ('queued', 'in_progress', 'completed'))", "position": 36 }, { "declaration": "\n CHECK (conclusion IS NULL OR conclusion IN ('success', 'failure', 'cancelled', 'skipped', 'timed_out'))", "position": 37 }, { "declaration": "\n CHECK (status <> 'completed' OR conclusion IS NOT NULL)", "position": 38 }, { "declaration": "\n CHECK (status = 'completed' OR conclusion IS NULL)", "position": 39 }, { "declaration": "\n CHECK (timeout_minutes IS NULL OR timeout_minutes > 0)", "position": 40 }, { "declaration": "\n CHECK (log_lines >= 0)", "position": 41 }, { "declaration": "\n CHECK (log_ack >= 0)", "position": 42 }, { "declaration": "\n CHECK (log_ack <= log_lines)", "position": 43 }, { "declaration": "\n CHECK (cancel_requested IN (0, 1))", "position": 44 }, { "declaration": "\n CHECK (requeues >= 0)", "position": 45 }, { "declaration": "\n CHECK (summary IS NULL OR length(summary) <= 65536)", "position": 46 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 47 }, { "declaration": "\n FOREIGN KEY (run_id) REFERENCES cotton_repo_runs(id)\n ", "position": 48 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_jobs (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_jobs_run ON cotton_repo_jobs (workspace_id, run_id, index_in_run)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_jobs_run_id ON cotton_repo_jobs (run_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_jobs_queue ON cotton_repo_jobs (workspace_id, status, created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_jobs_author ON cotton_repo_jobs (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_repo_merge_queue", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "pull_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n pull_id TEXT NOT NULL", "position": 3 }, { "name": "pull_number", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n pull_number INTEGER NOT NULL", "position": 4 }, { "name": "base_ref", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n base_ref TEXT NOT NULL", "position": 5 }, { "name": "head_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n head_sha TEXT", "position": 6 }, { "name": "state", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'queued'", "position": 7 }, { "name": "failures", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n failures INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reason TEXT", "position": 9 }, { "name": "train_number", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n train_number INTEGER", "position": 10 }, { "name": "train_base_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n train_base_sha TEXT", "position": 11 }, { "name": "train_tip_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n train_tip_sha TEXT", "position": 12 }, { "name": "train_run_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n train_run_id TEXT", "position": 13 }, { "name": "landed_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n landed_sha TEXT", "position": 14 }, { "name": "enqueued_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n enqueued_at TEXT NOT NULL", "position": 15 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 16 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 17 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 18 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 19 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 20 }, { "name": "train_squash_sha", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n train_squash_sha TEXT", "position": 21 } ], "constraints": [ { "declaration": "\n CHECK (length(repo_id) > 0)", "position": 22 }, { "declaration": "\n CHECK (length(pull_id) > 0)", "position": 23 }, { "declaration": "\n CHECK (pull_number > 0)", "position": 24 }, { "declaration": "\n CHECK (length(base_ref) > 0)", "position": 25 }, { "declaration": "\n CHECK (state IN ('queued', 'checking', 'landed', 'ejected'))", "position": 26 }, { "declaration": "\n CHECK (failures >= 0)", "position": 27 }, { "declaration": "\n CHECK (reason IS NULL OR length(reason) <= 2048)", "position": 28 }, { "declaration": "\n CHECK (train_number IS NULL OR train_number > 0)", "position": 29 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 30 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_merge_queue (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_merge_queue_author ON cotton_repo_merge_queue (substr(_hlc, 20), _hlc)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_merge_queue_repo ON cotton_repo_merge_queue (workspace_id, repo_id, state, enqueued_at)" ], "full_text": [], "triggers": [] } ] }, "restaurant": { "tables": [] }, "ride": { "tables": [] }, "run": { "engine": "ci", "tables": [ { "name": "cotton_repo_runs", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "index_in_repo", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n index_in_repo INTEGER NOT NULL", "position": 3 }, { "name": "workflow", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workflow TEXT NOT NULL", "position": 4 }, { "name": "workflow_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n workflow_name TEXT", "position": 5 }, { "name": "event", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n event TEXT NOT NULL", "position": 6 }, { "name": "ref", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n ref TEXT NOT NULL", "position": 7 }, { "name": "sha", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha TEXT NOT NULL", "position": 8 }, { "name": "pull_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n pull_id TEXT", "position": 9 }, { "name": "status", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'queued'", "position": 10 }, { "name": "conclusion", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n conclusion TEXT", "position": 11 }, { "name": "triggered_by", "type": "TEXT", "default": "'worker'", "nullable": false, "primary_key": false, "declaration": "\n triggered_by TEXT NOT NULL DEFAULT 'worker'", "position": 12 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n started_at TEXT", "position": 13 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 14 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, index_in_repo)", "position": 19 }, { "declaration": "\n CHECK (index_in_repo > 0)", "position": 20 }, { "declaration": "\n CHECK (length(trim(workflow)) > 0)", "position": 21 }, { "declaration": "\n CHECK (event IN ('push', 'pull_request', 'merge_group', 'schedule', 'workflow_dispatch'))", "position": 22 }, { "declaration": "\n CHECK (length(trim(ref)) > 0)", "position": 23 }, { "declaration": "\n CHECK (length(sha) BETWEEN 7 AND 64)", "position": 24 }, { "declaration": "\n CHECK (status IN ('queued', 'in_progress', 'completed'))", "position": 25 }, { "declaration": "\n CHECK (conclusion IS NULL OR conclusion IN ('success', 'failure', 'cancelled', 'skipped', 'timed_out'))", "position": 26 }, { "declaration": "\n CHECK (status <> 'completed' OR conclusion IS NOT NULL)", "position": 27 }, { "declaration": "\n CHECK (status = 'completed' OR conclusion IS NULL)", "position": 28 }, { "declaration": "\n CHECK (triggered_by IN ('worker', 'owner', 'schedule'))", "position": 29 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 30 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 31 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_runs (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_repo ON cotton_repo_runs (workspace_id, repo_id, index_in_repo DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_sha ON cotton_repo_runs (workspace_id, repo_id, sha)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_runs_author ON cotton_repo_runs (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "schema_move": { "engine": "sync", "tables": [] }, "screenplay": { "engine": "screenplay", "tables": [ { "name": "cotton_screenplays", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 2 }, { "name": "logline", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n logline TEXT", "position": 3 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 4 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 5 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n CHECK (length(trim(title)) > 0)", "position": 10 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 11 } ], "prefix": "CREATE TABLE cotton_screenplays (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_screenplays_workspace ON cotton_screenplays (workspace_id, archived_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_screenplays_author ON cotton_screenplays (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_screenplay_draft_scenes", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "draft_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n draft_id TEXT NOT NULL", "position": 2 }, { "name": "scene_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n scene_id TEXT NOT NULL", "position": 3 }, { "name": "position", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n \"position\" REAL NOT NULL", "position": 4 }, { "name": "heading", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n heading TEXT", "position": 5 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 6 }, { "name": "purpose", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n purpose TEXT", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n UNIQUE (draft_id, scene_id)", "position": 12 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 13 }, { "declaration": "\n FOREIGN KEY (draft_id) REFERENCES cotton_screenplay_drafts(id)\n ", "position": 14 } ], "prefix": "CREATE TABLE cotton_screenplay_draft_scenes (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_screenplay_draft_scenes_order ON cotton_screenplay_draft_scenes (draft_id, \"position\")", "CREATE INDEX IF NOT EXISTS idx_cotton_screenplay_draft_scenes_author ON cotton_screenplay_draft_scenes (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "screenplay_character": { "engine": "screenplay", "tables": [ { "name": "cotton_screenplay_characters", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "screenplay_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n screenplay_id TEXT NOT NULL", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 3 }, { "name": "aliases", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n aliases TEXT", "position": 4 }, { "name": "bio", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n bio TEXT", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 10 }, { "name": "want", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n want TEXT", "position": 11 }, { "name": "arc", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n arc TEXT", "position": 12 }, { "name": "age", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n age TEXT", "position": 13 }, { "name": "casting_thoughts", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n casting_thoughts TEXT", "position": 14 }, { "name": "picture_photo_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n picture_photo_id TEXT", "position": 15 } ], "constraints": [ { "declaration": "\n UNIQUE (screenplay_id, name)", "position": 16 }, { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 17 }, { "declaration": "\n CHECK (aliases IS NULL OR json_type(aliases) = 'array')", "position": 18 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 19 }, { "declaration": "\n FOREIGN KEY (screenplay_id) REFERENCES cotton_screenplays(id)\n ", "position": 20 } ], "prefix": "CREATE TABLE cotton_screenplay_characters (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_screenplay_characters_screenplay ON cotton_screenplay_characters (screenplay_id, name)", "CREATE INDEX IF NOT EXISTS idx_cotton_screenplay_characters_author ON cotton_screenplay_characters (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "screenplay_document": { "engine": "screenplay", "tables": [ { "name": "cotton_screenplay_documents", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "screenplay_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n screenplay_id TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 3 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n UNIQUE (screenplay_id, kind)", "position": 10 }, { "declaration": "\n CHECK (length(kind) BETWEEN 1 AND 40 AND NOT kind GLOB '*[^a-z0-9_-]*')", "position": 11 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 12 }, { "declaration": "\n FOREIGN KEY (screenplay_id) REFERENCES cotton_screenplays(id)\n ", "position": 13 } ], "prefix": "CREATE TABLE cotton_screenplay_documents (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_screenplay_documents_author ON cotton_screenplay_documents (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "screenplay_draft": { "engine": "screenplay", "tables": [ { "name": "cotton_screenplay_drafts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "screenplay_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n screenplay_id TEXT NOT NULL", "position": 2 }, { "name": "name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n name TEXT NOT NULL", "position": 3 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 4 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n CHECK (length(trim(name)) > 0)", "position": 8 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 9 }, { "declaration": "\n FOREIGN KEY (screenplay_id) REFERENCES cotton_screenplays(id)\n ", "position": 10 } ], "prefix": "CREATE TABLE cotton_screenplay_drafts (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_screenplay_drafts_screenplay ON cotton_screenplay_drafts (screenplay_id, created_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_screenplay_drafts_author ON cotton_screenplay_drafts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "screenplay_scene": { "engine": "screenplay", "tables": [ { "name": "cotton_screenplay_scenes", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "screenplay_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n screenplay_id TEXT NOT NULL", "position": 2 }, { "name": "position", "type": "REAL", "default": null, "nullable": false, "primary_key": false, "declaration": "\n \"position\" REAL NOT NULL", "position": 3 }, { "name": "heading", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n heading TEXT", "position": 4 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 5 }, { "name": "purpose", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n purpose TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "archived_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n archived_at TEXT", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 }, { "name": "act", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n act TEXT", "position": 12 }, { "name": "sequence", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sequence TEXT", "position": 13 }, { "name": "status", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n status TEXT", "position": 14 }, { "name": "location", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n location TEXT", "position": 15 }, { "name": "characters_in_scene", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n characters_in_scene TEXT", "position": 16 }, { "name": "characters_set_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n characters_set_by TEXT", "position": 17 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n CHECK (act IS NULL OR act IN ('1', '2', '3', '4', '5'))", "position": 19 }, { "declaration": "\n CHECK (status IS NULL OR status IN ('outline', 'drafted', 'locked'))", "position": 20 }, { "declaration": "\n CHECK (characters_set_by IS NULL OR characters_set_by IN ('engine', 'owner'))", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 22 }, { "declaration": "\n FOREIGN KEY (screenplay_id) REFERENCES cotton_screenplays(id)\n ", "position": 23 } ], "prefix": "CREATE TABLE cotton_screenplay_scenes (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_screenplay_scenes_order ON cotton_screenplay_scenes (screenplay_id, \"position\")", "CREATE INDEX IF NOT EXISTS idx_cotton_screenplay_scenes_author ON cotton_screenplay_scenes (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "secret": { "engine": "vault", "tables": [] }, "session": { "engine": "sessions", "tables": [ { "name": "cotton_sessions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "project_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n project_id TEXT", "position": 2 }, { "name": "tool", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n tool TEXT NOT NULL", "position": 3 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_id TEXT", "position": 4 }, { "name": "machine", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n machine TEXT", "position": 5 }, { "name": "repo_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n repo_url TEXT", "position": 6 }, { "name": "branch", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n branch TEXT", "position": 7 }, { "name": "cwd", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cwd TEXT", "position": 8 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n started_at TEXT", "position": 9 }, { "name": "last_active_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n last_active_at TEXT NOT NULL", "position": 10 }, { "name": "ended_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ended_at TEXT", "position": 11 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 12 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 13 }, { "name": "shipped", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n shipped TEXT NOT NULL DEFAULT '[]'", "position": 14 }, { "name": "turn_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n turn_count INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "prompt_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n prompt_count INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "transcript_ref", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n transcript_ref TEXT", "position": 17 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 18 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 19 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 20 }, { "name": "account", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " account TEXT", "position": 21 }, { "name": "listened_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " listened_at TEXT", "position": 22 }, { "name": "model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " model TEXT", "position": 23 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 24 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n device_id TEXT", "position": 25 }, { "name": "state", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n state TEXT CHECK (state IS NULL OR state IN ('queued', 'starting', 'running', 'idle', 'waiting', 'ended', 'failed', 'withdrawn'))", "position": 26 }, { "name": "state_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n state_at TEXT", "position": 27 }, { "name": "waiting_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n waiting_kind TEXT CHECK (waiting_kind IS NULL OR waiting_kind IN ('permission', 'question', 'input'))", "position": 28 }, { "name": "waiting_ref", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n waiting_ref TEXT", "position": 29 }, { "name": "last_line", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_line TEXT CHECK (last_line IS NULL OR length(last_line) <= 280)", "position": 30 }, { "name": "exit_code", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n exit_code INTEGER", "position": 31 }, { "name": "permission_mode", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n permission_mode TEXT CHECK (permission_mode IS NULL OR permission_mode IN ('bypass', 'ask'))", "position": 32 }, { "name": "host_owned", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n host_owned INTEGER NOT NULL DEFAULT 0 CHECK (host_owned IN (0, 1))", "position": 33 }, { "name": "todo_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n todo_id TEXT", "position": 34 }, { "name": "requested_device_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n requested_device_id TEXT", "position": 35 }, { "name": "chosen_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n chosen_by TEXT CHECK (chosen_by IS NULL OR chosen_by IN ('owner', 'dispatcher'))", "position": 36 }, { "name": "prompt", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n prompt TEXT NOT NULL DEFAULT ''", "position": 37 }, { "name": "hold_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n hold_reason TEXT CHECK (hold_reason IS NULL OR length(hold_reason) <= 200)", "position": 38 }, { "name": "claimed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n claimed_at TEXT", "position": 39 }, { "name": "report_message_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n report_message_id TEXT", "position": 40 }, { "name": "error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error TEXT", "position": 41 }, { "name": "kind", "type": "TEXT", "default": "'thread'", "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL DEFAULT 'thread' CHECK (kind IN ('conversation', 'thread'))", "position": 42 }, { "name": "parent_session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n parent_session_id TEXT", "position": 43 }, { "name": "todo_database", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n todo_database TEXT CHECK (todo_database IS NULL OR length(todo_database) > 0)", "position": 44 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 45 } ], "constraints": [ { "declaration": "\n UNIQUE (tool, external_id)", "position": 46 }, { "declaration": "\n CHECK (tool IN ('claude-code', 'codex', 'kimi', 'gemini', 'opencode', 'other'))", "position": 47 }, { "declaration": "\n CHECK (external_id IS NULL OR length(trim(external_id)) > 0)", "position": 48 }, { "declaration": "\n CHECK (machine IS NULL OR length(trim(machine)) > 0)", "position": 49 }, { "declaration": "\n CHECK ((summary IS NULL) OR (length(summary) <= 2000))", "position": 50 }, { "declaration": "\n CHECK ((title IS NULL) OR (length(title) <= 140))", "position": 51 }, { "declaration": "\n CHECK (json_type(shipped) = 'array')", "position": 52 }, { "declaration": "\n CHECK (turn_count >= 0)", "position": 53 }, { "declaration": "\n CHECK (prompt_count >= 0)", "position": 54 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 55 } ], "prefix": "CREATE TABLE cotton_sessions (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_sessions_recent ON cotton_sessions (workspace_id, last_active_at DESC)", "CREATE INDEX idx_cotton_sessions_project ON cotton_sessions (project_id, last_active_at DESC) WHERE project_id IS NOT NULL", "CREATE INDEX idx_cotton_sessions_machine ON cotton_sessions (workspace_id, machine, last_active_at DESC)", "CREATE INDEX idx_cotton_sessions_queue ON cotton_sessions (workspace_id, state, device_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_sessions_author ON cotton_sessions (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX IF NOT EXISTS idx_cotton_sessions_conversation ON cotton_sessions (project_id) WHERE kind = 'conversation'", "CREATE INDEX IF NOT EXISTS idx_cotton_sessions_parent ON cotton_sessions (parent_session_id, last_active_at DESC) WHERE parent_session_id IS NOT NULL" ], "full_text": [], "triggers": [] }, { "name": "cotton_session_tasks", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "session_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n session_id TEXT NOT NULL", "position": 2 }, { "name": "seq", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n seq INTEGER NOT NULL", "position": 3 }, { "name": "text", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n text TEXT NOT NULL", "position": 4 }, { "name": "state", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 7 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 8 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 9 } ], "constraints": [ { "declaration": "\n UNIQUE (session_id, seq)", "position": 10 }, { "declaration": "\n CHECK (seq >= 0)", "position": 11 }, { "declaration": "\n CHECK (length(text) <= 500)", "position": 12 }, { "declaration": "\n CHECK (state IN ('open', 'active', 'done'))", "position": 13 }, { "declaration": "\n FOREIGN KEY (session_id) REFERENCES cotton_sessions(id)", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_session_tasks (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_session_tasks_author ON cotton_session_tasks (substr(_hlc, 20), _hlc)", "CREATE INDEX IF NOT EXISTS idx_cotton_session_tasks_session ON cotton_session_tasks (session_id, seq)" ], "full_text": [], "triggers": [] }, { "name": "cotton_dev_jobs", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "device_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n device_id TEXT NOT NULL", "position": 2 }, { "name": "command", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n command TEXT NOT NULL", "position": 3 }, { "name": "cwd", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cwd TEXT", "position": 4 }, { "name": "timeout_seconds", "type": "INTEGER", "default": "300", "nullable": false, "primary_key": false, "declaration": "\n timeout_seconds INTEGER NOT NULL DEFAULT 300", "position": 5 }, { "name": "state", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'queued'", "position": 6 }, { "name": "exit_code", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n exit_code INTEGER", "position": 7 }, { "name": "failure", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n failure TEXT", "position": 8 }, { "name": "log_path", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n log_path TEXT", "position": 9 }, { "name": "log_bytes", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n log_bytes INTEGER NOT NULL DEFAULT 0", "position": 10 }, { "name": "log_lines", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n log_lines INTEGER NOT NULL DEFAULT 0", "position": 11 }, { "name": "output_tail", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n output_tail TEXT", "position": 12 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 13 }, { "name": "claimed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n claimed_at TEXT", "position": 14 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 15 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 16 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 17 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 18 } ], "constraints": [ { "declaration": "\n CHECK (length(device_id) > 0)", "position": 19 }, { "declaration": "\n CHECK (length(trim(command)) > 0)", "position": 20 }, { "declaration": "\n CHECK (length(command) <= 4096)", "position": 21 }, { "declaration": "\n CHECK (cwd IS NULL OR length(trim(cwd)) > 0)", "position": 22 }, { "declaration": "\n CHECK (timeout_seconds > 0)", "position": 23 }, { "declaration": "\n CHECK (timeout_seconds <= 3600)", "position": 24 }, { "declaration": "\n CHECK (state IN ('queued', 'running', 'done', 'failed', 'expired'))", "position": 25 }, { "declaration": "\n CHECK (log_bytes >= 0)", "position": 26 }, { "declaration": "\n CHECK (log_lines >= 0)", "position": 27 }, { "declaration": "\n CHECK (output_tail IS NULL OR length(output_tail) <= 65536)", "position": 28 }, { "declaration": "\n CHECK (failure IS NULL OR length(failure) <= 2048)", "position": 29 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 30 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_dev_jobs (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_dev_jobs_author ON cotton_dev_jobs (substr(_hlc, 20), _hlc)", "CREATE INDEX IF NOT EXISTS idx_cotton_dev_jobs_queue ON cotton_dev_jobs (workspace_id, device_id, state, created_at)" ], "full_text": [], "triggers": [] } ] }, "session_message": { "engine": "sessions", "tables": [ { "name": "cotton_session_messages", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "project_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n project_id TEXT", "position": 2 }, { "name": "to_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n to_kind TEXT NOT NULL", "position": 3 }, { "name": "to_session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n to_session_id TEXT", "position": 4 }, { "name": "from_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n from_kind TEXT NOT NULL", "position": 5 }, { "name": "from_session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n from_session_id TEXT", "position": 6 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 7 }, { "name": "body", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n body TEXT NOT NULL", "position": 8 }, { "name": "reply_to", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reply_to TEXT", "position": 9 }, { "name": "request_ref", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n request_ref TEXT", "position": 10 }, { "name": "thought_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n thought_id TEXT", "position": 11 }, { "name": "status", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'open'", "position": 12 }, { "name": "claimed_by_session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n claimed_by_session_id TEXT", "position": 13 }, { "name": "claimed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n claimed_at TEXT", "position": 14 }, { "name": "done_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n done_at TEXT", "position": 15 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 16 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 17 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 18 }, { "name": "media", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": " media TEXT NOT NULL DEFAULT '[]' CHECK (json_type(media) = 'array')", "position": 19 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 20 } ], "constraints": [ { "declaration": "\n CHECK (to_kind IN ('owner', 'project', 'session'))", "position": 21 }, { "declaration": "\n CHECK (from_kind IN ('owner', 'session'))", "position": 22 }, { "declaration": "\n CHECK (kind IN ('instruction', 'question', 'answer', 'report', 'decision', 'stop'))", "position": 23 }, { "declaration": "\n CHECK (status IN ('open', 'claimed', 'done', 'withdrawn'))", "position": 24 }, { "declaration": "\n CHECK (length(trim(body)) > 0 AND length(body) <= 8000)", "position": 25 }, { "declaration": "\n CHECK (to_kind <> 'session' OR to_session_id IS NOT NULL)", "position": 26 }, { "declaration": "\n CHECK (to_kind <> 'project' OR project_id IS NOT NULL)", "position": 27 }, { "declaration": "\n CHECK (from_kind <> 'session' OR from_session_id IS NOT NULL)", "position": 28 }, { "declaration": "\n CHECK (kind NOT IN ('decision', 'stop') OR to_kind = 'session')", "position": 29 }, { "declaration": "\n CHECK (kind <> 'decision' OR request_ref IS NOT NULL)", "position": 30 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 31 }, { "declaration": "\n FOREIGN KEY (to_session_id) REFERENCES cotton_sessions(id)\n ", "position": 32 } ], "prefix": "CREATE TABLE cotton_session_messages (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_session_messages_addressed\n ON cotton_session_messages (workspace_id, status, to_kind, to_session_id)", "CREATE INDEX idx_cotton_session_messages_project\n ON cotton_session_messages (workspace_id, project_id, status)", "CREATE INDEX IF NOT EXISTS idx_cotton_session_messages_author ON cotton_session_messages (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_session_messages USING fts5(\n body, content = 'cotton_session_messages', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_session_messages_ai AFTER INSERT ON cotton_session_messages WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_session_messages'), 0) BEGIN\n INSERT INTO fts_session_messages (rowid, body) VALUES (new.rowid, new.body);\n END", "CREATE TRIGGER fts_session_messages_ad AFTER DELETE ON cotton_session_messages WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_session_messages'), 0) BEGIN\n INSERT INTO fts_session_messages (fts_session_messages, rowid, body) VALUES ('delete', old.rowid, old.body);\n END", "CREATE TRIGGER fts_session_messages_au AFTER UPDATE OF body ON cotton_session_messages\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_session_messages'), 0) AND (new.body IS NOT old.body) BEGIN\n INSERT INTO fts_session_messages (fts_session_messages, rowid, body) VALUES ('delete', old.rowid, old.body);\n INSERT INTO fts_session_messages (rowid, body) VALUES (new.rowid, new.body);\n END" ] } ] }, "settings": { "engine": "settings", "tables": [] }, "sighting": { "engine": "media", "tables": [ { "name": "cotton_media_sightings", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 2 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 3 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 4 }, { "name": "source_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_id TEXT", "position": 5 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n thread_id TEXT", "position": 6 }, { "name": "key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n key TEXT NOT NULL", "position": 7 }, { "name": "seen_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n seen_at TEXT NOT NULL", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n CHECK (record_kind IN ('photo', 'video'))", "position": 13 }, { "declaration": "\n CHECK (substr(record_id, 1, length(record_kind) + 1) = record_kind || ':')", "position": 14 }, { "declaration": "\n CHECK (source IN ('message', 'share', 'library', 'apple_library', 'email'))", "position": 15 }, { "declaration": "\n CHECK ((source = 'message') = (thread_id IS NOT NULL))", "position": 16 }, { "declaration": "\n CHECK (source NOT IN ('message', 'apple_library', 'email') OR source_id IS NOT NULL)", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 18 } ], "prefix": "CREATE TABLE \"cotton_media_sightings\" (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_media_sightings_natural ON cotton_media_sightings (workspace_id, record_kind, record_id, source, ifnull(source_id, ''))", "CREATE INDEX idx_cotton_media_sightings_record ON cotton_media_sightings (workspace_id, record_id)", "CREATE INDEX idx_cotton_media_sightings_thread ON cotton_media_sightings (workspace_id, thread_id) WHERE thread_id IS NOT NULL", "CREATE INDEX idx_cotton_media_sightings_source ON cotton_media_sightings (workspace_id, source, source_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_media_sightings_author ON cotton_media_sightings (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "so_far": { "tables": [] }, "statement": { "engine": "money", "tables": [ { "name": "cotton_money_statements", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "document_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n document_id TEXT NOT NULL", "position": 2 }, { "name": "account_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n account_id TEXT", "position": 3 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 4 }, { "name": "period_start", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_start TEXT", "position": 5 }, { "name": "period_end", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n period_end TEXT", "position": 6 }, { "name": "opening_balance_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n opening_balance_minor INTEGER", "position": 7 }, { "name": "closing_balance_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n closing_balance_minor INTEGER", "position": 8 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n currency TEXT NOT NULL", "position": 9 }, { "name": "read_status", "type": "TEXT", "default": "'pending'", "nullable": false, "primary_key": false, "declaration": "\n read_status TEXT NOT NULL DEFAULT 'pending'", "position": 10 }, { "name": "read_error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_error TEXT", "position": 11 }, { "name": "read_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_by TEXT", "position": 12 }, { "name": "read_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n read_at TEXT", "position": 13 }, { "name": "line_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n line_count INTEGER NOT NULL DEFAULT 0", "position": 14 }, { "name": "sum_in_minor", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sum_in_minor INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "sum_out_minor", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n sum_out_minor INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "balance_check", "type": "TEXT", "default": "'unknown'", "nullable": false, "primary_key": false, "declaration": "\n balance_check TEXT NOT NULL DEFAULT 'unknown'", "position": 17 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 18 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 19 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 20 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 21 } ], "constraints": [ { "declaration": "\n UNIQUE (document_id)", "position": 22 }, { "declaration": "\n CHECK (balance_check IN ('ok', 'mismatch', 'unknown'))", "position": 23 }, { "declaration": "\n CHECK (kind IN ('bank', 'credit_card'))", "position": 24 }, { "declaration": "\n CHECK (line_count >= 0)", "position": 25 }, { "declaration": "\n CHECK ((period_start IS NULL) OR (period_end IS NULL) OR (period_end >= period_start))", "position": 26 }, { "declaration": "\n CHECK (read_status IN ('pending', 'read', 'mismatch', 'failed'))", "position": 27 }, { "declaration": "\n FOREIGN KEY (document_id) REFERENCES cotton_documents(id)", "position": 28 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 29 } ], "prefix": "CREATE TABLE cotton_money_statements (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_money_statements_account ON cotton_money_statements (account_id, period_start) WHERE account_id IS NOT NULL", "CREATE INDEX idx_cotton_money_statements_pending ON cotton_money_statements (created_at) WHERE read_status = 'pending'", "CREATE INDEX idx_cotton_money_statements_workspace ON cotton_money_statements (workspace_id, period_start DESC)", "CREATE INDEX IF NOT EXISTS idx_cotton_money_statements_author ON cotton_money_statements (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "statement_line": { "engine": "money", "tables": [ { "name": "cotton_money_statement_lines", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "statement_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n statement_id TEXT NOT NULL", "position": 2 }, { "name": "page", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n page INTEGER NOT NULL", "position": 3 }, { "name": "line_no", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n line_no INTEGER NOT NULL", "position": 4 }, { "name": "posted_on", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n posted_on TEXT NOT NULL", "position": 5 }, { "name": "text", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n text TEXT NOT NULL", "position": 6 }, { "name": "amount_minor", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n amount_minor INTEGER NOT NULL", "position": 7 }, { "name": "direction", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n direction TEXT NOT NULL", "position": 8 }, { "name": "balance_after_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n balance_after_minor INTEGER", "position": 9 }, { "name": "reference", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reference TEXT", "position": 10 }, { "name": "fingerprint", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n fingerprint TEXT NOT NULL", "position": 11 }, { "name": "ignored_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n ignored_reason TEXT", "position": 12 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 13 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 14 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 15 } ], "constraints": [ { "declaration": "\n UNIQUE (statement_id, line_no)", "position": 16 }, { "declaration": "\n CHECK (amount_minor > 0)", "position": 17 }, { "declaration": "\n CHECK (direction IN ('in', 'out'))", "position": 18 }, { "declaration": "\n CHECK (length(trim(text)) > 0)", "position": 19 }, { "declaration": "\n CHECK (line_no >= 1)", "position": 20 }, { "declaration": "\n CHECK (page >= 1)", "position": 21 }, { "declaration": "\n FOREIGN KEY (statement_id) REFERENCES cotton_money_statements(id)", "position": 22 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 23 } ], "prefix": "CREATE TABLE cotton_money_statement_lines (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_money_statement_lines_statement ON cotton_money_statement_lines (statement_id, line_no)", "CREATE INDEX idx_cotton_money_statement_lines_workspace ON cotton_money_statement_lines (workspace_id)", "CREATE UNIQUE INDEX uq_cotton_money_statement_lines_fingerprint ON cotton_money_statement_lines (statement_id, fingerprint)", "CREATE INDEX idx_cotton_money_statement_lines_fingerprint ON cotton_money_statement_lines (fingerprint)", "CREATE INDEX IF NOT EXISTS idx_cotton_money_statement_lines_author ON cotton_money_statement_lines (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [ "CREATE TRIGGER cotton_money_statement_lines_no_delete_booked\n BEFORE DELETE ON cotton_money_statement_lines\n WHEN EXISTS (SELECT 1 FROM cotton_money_evidence AS e WHERE e.kind = 'statement_line' AND e.ref_id = OLD.id)\n BEGIN SELECT RAISE(ABORT, 'a booked statement line is never deleted'); END" ] } ] }, "storage": { "engine": "storage", "tables": [] }, "story": { "engine": "messages", "tables": [ { "name": "cotton_stories", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL CHECK (source IN ('whatsapp', 'instagram', 'facebook'))", "position": 2 }, { "name": "account", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n account TEXT NOT NULL", "position": 3 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_id TEXT NOT NULL", "position": 4 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 5 }, { "name": "sender", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender TEXT", "position": 6 }, { "name": "sender_label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_label TEXT", "position": 7 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 8 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 9 }, { "name": "media_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n media_key TEXT", "position": 10 }, { "name": "media_content_type", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n media_content_type TEXT", "position": 11 }, { "name": "media_dropped_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n media_dropped_at TEXT", "position": 12 }, { "name": "posted_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n posted_at TEXT NOT NULL", "position": 13 }, { "name": "expires_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n expires_at TEXT NOT NULL", "position": 14 }, { "name": "seen_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n seen_at TEXT", "position": 15 }, { "name": "kept", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n kept INTEGER NOT NULL DEFAULT 0 CHECK (kept IN (0, 1))", "position": 16 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 17 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 18 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 19 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, source, external_id)", "position": 20 }, { "declaration": "\n CHECK (trim(external_id) <> '')", "position": 21 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 22 } ], "prefix": "CREATE TABLE cotton_stories (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_stories_posted ON cotton_stories (workspace_id, posted_at)", "CREATE INDEX idx_cotton_stories_person ON cotton_stories (person_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_stories_author ON cotton_stories (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "theme": { "engine": "themes", "tables": [] }, "thought": { "engine": "thoughts", "tables": [ { "name": "cotton_thought_attachments", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thought_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thought_id TEXT NOT NULL", "position": 2 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_kind TEXT NOT NULL", "position": 3 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n record_id TEXT NOT NULL", "position": 4 }, { "name": "position", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n position INTEGER NOT NULL", "position": 5 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n UNIQUE (thought_id, record_kind, record_id)", "position": 11 }, { "declaration": "\n CHECK (record_kind IN ('photo', 'video', 'document'))", "position": 12 }, { "declaration": "\n CHECK (length(record_id) > 0)", "position": 13 }, { "declaration": "\n CHECK (position >= 0)", "position": 14 }, { "declaration": "\n CHECK (caption IS NULL OR length(caption) <= 500)", "position": 15 }, { "declaration": "\n FOREIGN KEY (thought_id) REFERENCES cotton_inbox_items(id)", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_thought_attachments (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_thought_attachments_author ON cotton_thought_attachments (substr(_hlc, 20), _hlc)", "CREATE INDEX IF NOT EXISTS idx_cotton_thought_attachments_thought ON cotton_thought_attachments (thought_id, position)" ], "full_text": [], "triggers": [] }, { "name": "cotton_inbox_items", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "raw_text", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n raw_text TEXT", "position": 2 }, { "name": "audio_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n audio_url TEXT", "position": 3 }, { "name": "captured_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n captured_at TEXT NOT NULL", "position": 4 }, { "name": "route_status", "type": "TEXT", "default": "'pending'", "nullable": false, "primary_key": false, "declaration": "\n route_status TEXT NOT NULL DEFAULT 'pending'", "position": 5 }, { "name": "routed_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n routed_kind TEXT", "position": 6 }, { "name": "routed_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n routed_id TEXT", "position": 7 }, { "name": "route_confidence", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n route_confidence TEXT", "position": 8 }, { "name": "correction_of", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n correction_of TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "transcript", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n transcript TEXT", "position": 12 }, { "name": "route_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n route_reason TEXT", "position": 13 }, { "name": "route_proposal", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n route_proposal TEXT", "position": 14 }, { "name": "routed_records", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n routed_records TEXT", "position": 15 }, { "name": "route_plan", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n route_plan TEXT", "position": 16 }, { "name": "route_plan_user_edited", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n route_plan_user_edited INTEGER", "position": 17 }, { "name": "swept_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n -- v20: the chat sweep's two marks on a capture.\n swept_at TEXT", "position": 18 }, { "name": "sweep_note", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sweep_note TEXT", "position": 19 }, { "name": "said_table", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n -- v75: where the thought was said (Spec 7): the tool's table when it\n -- was said inside one, and the record when it was said on a record's\n -- page. Both NULL for a thought said on the database's own page.\n -- capture.create refuses a record without its table; no constraint here, a\n -- synced row arrives column by column (tests/no_cross_column_checks.rs).\n said_table TEXT", "position": 20 }, { "name": "said_record_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n said_record_id TEXT", "position": 21 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 22 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 23 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 24 } ], "constraints": [ { "declaration": "\n CHECK ((raw_text IS NOT NULL) OR (audio_url IS NOT NULL))", "position": 25 }, { "declaration": "\n CHECK (route_status IN ('pending', 'routed', 'corrected', 'dismissed'))", "position": 26 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 27 } ], "prefix": "CREATE TABLE \"cotton_inbox_items\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_inbox_items_workspace ON cotton_inbox_items (workspace_id, route_status)", "CREATE INDEX idx_cotton_inbox_items_said ON cotton_inbox_items (said_table, said_record_id) WHERE said_table IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_inbox_items_author ON cotton_inbox_items (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_thoughts USING fts5(\n raw_text, content = 'cotton_inbox_items', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_thoughts_ai AFTER INSERT ON cotton_inbox_items WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_thoughts'), 0) BEGIN\n INSERT INTO fts_thoughts (rowid, raw_text) VALUES (new.rowid, new.raw_text);\n END", "CREATE TRIGGER fts_thoughts_ad AFTER DELETE ON cotton_inbox_items WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_thoughts'), 0) BEGIN\n INSERT INTO fts_thoughts (fts_thoughts, rowid, raw_text) VALUES ('delete', old.rowid, old.raw_text);\n END", "CREATE TRIGGER fts_thoughts_au AFTER UPDATE OF raw_text ON cotton_inbox_items\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_thoughts'), 0) AND (new.raw_text IS NOT old.raw_text) BEGIN\n INSERT INTO fts_thoughts (fts_thoughts, rowid, raw_text) VALUES ('delete', old.rowid, old.raw_text);\n INSERT INTO fts_thoughts (rowid, raw_text) VALUES (new.rowid, new.raw_text);\n END" ] } ] }, "thread": { "engine": "messages", "tables": [ { "name": "cotton_msg_owner_settings", "columns": [ { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n workspace_id TEXT PRIMARY KEY", "position": 0 }, { "name": "handle", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n handle TEXT NOT NULL", "position": 1 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n display_name TEXT NOT NULL", "position": 2 }, { "name": "avatar_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_url TEXT", "position": 3 }, { "name": "availability_copy", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n availability_copy TEXT", "position": 4 }, { "name": "allow_new_contacts", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n allow_new_contacts INTEGER NOT NULL DEFAULT 1", "position": 5 }, { "name": "app_download_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n app_download_url TEXT", "position": 6 }, { "name": "read_receipts", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n read_receipts INTEGER NOT NULL DEFAULT 1", "position": 7 }, { "name": "discoverable", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n discoverable INTEGER NOT NULL DEFAULT 1", "position": 8 }, { "name": "last_seen_visible", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n last_seen_visible INTEGER NOT NULL DEFAULT 1", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "share_requests", "type": "TEXT", "default": "'contacts_direct'", "nullable": false, "primary_key": false, "declaration": " share_requests TEXT NOT NULL DEFAULT 'contacts_direct' CHECK (share_requests IN ('contacts_direct','ask_always'))", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n CHECK (handle NOT IN ('inbox', 'api', 'assets', 'admin', 'settings', 'download', 'privacy', 'terms', 'about', 'app', 'm'))", "position": 15 }, { "declaration": "\n CHECK (length(handle) BETWEEN 3 AND 30 AND NOT handle GLOB '*[^a-z0-9-]*')", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE cotton_msg_owner_settings (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_msg_owner_settings_handle ON cotton_msg_owner_settings (handle)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_owner_settings_author ON cotton_msg_owner_settings (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_reactions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "message_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n message_id TEXT NOT NULL", "position": 3 }, { "name": "actor", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n actor TEXT NOT NULL", "position": 4 }, { "name": "emoji", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n emoji TEXT NOT NULL", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 } ], "constraints": [ { "declaration": "\n UNIQUE (message_id, actor)", "position": 9 }, { "declaration": "\n CHECK (trim(actor) <> '')", "position": 10 }, { "declaration": "\n CHECK (trim(emoji) <> '' AND length(emoji) <= 8)", "position": 11 }, { "declaration": "\n FOREIGN KEY (message_id) REFERENCES cotton_msg_messages(id)", "position": 12 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE cotton_msg_reactions (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_reactions_message ON cotton_msg_reactions (message_id)", "CREATE INDEX idx_cotton_msg_reactions_workspace ON cotton_msg_reactions (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_reactions_author ON cotton_msg_reactions (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_threads", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n contact_id TEXT", "position": 2 }, { "name": "kind", "type": "TEXT", "default": "'dm'", "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL DEFAULT 'dm'", "position": 3 }, { "name": "last_message_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_message_at TEXT", "position": 4 }, { "name": "last_message_preview", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_message_preview TEXT", "position": 5 }, { "name": "archived", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n archived INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 9 }, { "name": "external_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_key TEXT", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "photo_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " photo_key TEXT", "position": 12 }, { "name": "description", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " description TEXT", "position": 13 }, { "name": "created_by_phone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " created_by_phone TEXT", "position": 14 }, { "name": "read_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " read_seq INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "delivered_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " delivered_seq INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "muted_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " muted_until TEXT", "position": 17 }, { "name": "pinned_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " pinned_at TEXT", "position": 18 }, { "name": "unread_marked_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " unread_marked_at TEXT", "position": 19 }, { "name": "draft", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " draft TEXT", "position": 20 }, { "name": "draft_reply_to_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " draft_reply_to_id TEXT", "position": 21 }, { "name": "cleared_before", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " cleared_before TEXT", "position": 22 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary TEXT CHECK ((summary IS NULL) OR (length(summary) <= 4000))", "position": 23 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary_updated_at TEXT", "position": 24 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary_by TEXT CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 25 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 26 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 27 } ], "constraints": [ { "declaration": "\n CHECK (kind IN ('dm', 'group'))", "position": 28 }, { "declaration": "\n CHECK (((kind = 'dm') AND ((contact_id IS NOT NULL) OR (NULLIF(trim(COALESCE(title, '')), '') IS NOT NULL))) OR ((kind = 'group') AND (contact_id IS NULL) AND (NULLIF(trim(COALESCE(title, '')), '') IS NOT NULL)))", "position": 29 }, { "declaration": "\n FOREIGN KEY (contact_id) REFERENCES cotton_msg_contacts(id)", "position": 30 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 31 } ], "prefix": "CREATE TABLE \"cotton_msg_threads\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_threads_contact ON cotton_msg_threads (contact_id)", "CREATE INDEX idx_cotton_msg_threads_workspace_recent ON cotton_msg_threads (workspace_id, last_message_at DESC)", "CREATE UNIQUE INDEX uq_cotton_msg_threads_dm ON cotton_msg_threads (workspace_id, contact_id) WHERE kind = 'dm'", "CREATE UNIQUE INDEX uq_cotton_msg_threads_group_key ON cotton_msg_threads (workspace_id, external_key) WHERE external_key IS NOT NULL", "CREATE INDEX idx_cotton_msg_threads_pinned ON cotton_msg_threads (workspace_id, pinned_at) WHERE pinned_at IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_threads_author ON cotton_msg_threads (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_contacts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "phone_e164", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n phone_e164 TEXT", "position": 2 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n display_name TEXT", "position": 3 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 4 }, { "name": "auth_user_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n auth_user_id TEXT", "position": 5 }, { "name": "vip", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n vip INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "muted", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n muted INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "blocked", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n blocked INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "on_cotton_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n on_cotton_at TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 }, { "name": "avatar_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_key TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, phone_e164)", "position": 15 }, { "declaration": "\n CHECK (phone_e164 IS NULL OR (length(phone_e164) BETWEEN 8 AND 15 AND NOT phone_e164 GLOB '*[^0-9]*'))", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE \"cotton_msg_contacts\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_contacts_auth_user ON cotton_msg_contacts (auth_user_id) WHERE auth_user_id IS NOT NULL", "CREATE INDEX idx_cotton_msg_contacts_workspace ON cotton_msg_contacts (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_contacts_author ON cotton_msg_contacts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_receipts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "phone", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n phone TEXT NOT NULL", "position": 3 }, { "name": "delivered_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n delivered_seq INTEGER NOT NULL DEFAULT 0", "position": 4 }, { "name": "read_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n read_seq INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 } ], "constraints": [ { "declaration": "\n UNIQUE (thread_id, phone)", "position": 9 }, { "declaration": "\n CHECK ((length(phone) BETWEEN 8 AND 15 AND NOT phone GLOB '*[^0-9]*') OR (length(phone) BETWEEN 2 AND 31 AND phone GLOB '[a-z0-9]*' AND NOT phone GLOB '*[^a-z0-9-]*' AND phone GLOB '*[^0-9]*'))", "position": 10 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 11 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 12 } ], "prefix": "CREATE TABLE \"cotton_msg_receipts\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_receipts_thread ON cotton_msg_receipts (thread_id)", "CREATE INDEX idx_cotton_msg_receipts_workspace ON cotton_msg_receipts (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_receipts_author ON cotton_msg_receipts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_contact_handles", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n contact_id TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 3 }, { "name": "value", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n value TEXT NOT NULL", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, kind, value)", "position": 8 }, { "declaration": "\n CHECK (kind IN ('phone', 'email', 'cotton', 'instagram', 'facebook', 'linkedin'))", "position": 9 }, { "declaration": "\n CHECK (kind <> 'phone' OR (length(value) BETWEEN 8 AND 15 AND NOT value GLOB '*[^0-9]*'))", "position": 10 }, { "declaration": "\n CHECK (kind <> 'email' OR (value = lower(value) AND value LIKE '%_@_%' AND value NOT GLOB '* *'))", "position": 11 }, { "declaration": "\n CHECK (kind <> 'cotton' OR (length(value) BETWEEN 2 AND 31 AND value GLOB '[a-z0-9]*' AND NOT value GLOB '*[^a-z0-9-]*' AND value GLOB '*[^0-9]*'))", "position": 12 }, { "declaration": "\n FOREIGN KEY (contact_id) REFERENCES cotton_msg_contacts(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE \"cotton_msg_contact_handles\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_contact_handles_contact ON cotton_msg_contact_handles (contact_id)", "CREATE INDEX idx_cotton_msg_contact_handles_workspace ON cotton_msg_contact_handles (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_contact_handles_author ON cotton_msg_contact_handles (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_thread_filings", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "database_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n database_id TEXT NOT NULL CHECK (length(trim(database_id)) > 0)", "position": 3 }, { "name": "state", "type": "TEXT", "default": "'filed'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'filed' CHECK (state IN ('filed','paused','unfiled'))", "position": 4 }, { "name": "paused_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n paused_by TEXT", "position": 5 }, { "name": "copied_through", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n copied_through TEXT", "position": 6 }, { "name": "filed_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n filed_at TEXT NOT NULL", "position": 7 }, { "name": "unfiled_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n unfiled_at TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_msg_thread_filings (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_msg_thread_filings_author ON cotton_msg_thread_filings (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX uq_cotton_msg_thread_filings_pair ON cotton_msg_thread_filings (workspace_id, thread_id, database_id)", "CREATE INDEX idx_cotton_msg_thread_filings_state ON cotton_msg_thread_filings (workspace_id, state)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_thread_marks", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "database_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n database_id TEXT NOT NULL CHECK (length(trim(database_id)) > 0)", "position": 2 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL CHECK (length(trim(thread_id)) > 0)", "position": 3 }, { "name": "pinned_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n pinned_at TEXT", "position": 4 }, { "name": "muted_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n muted_until TEXT", "position": 5 }, { "name": "archived", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n archived INTEGER NOT NULL DEFAULT 0 CHECK (archived IN (0,1))", "position": 6 }, { "name": "cleared_before", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cleared_before TEXT", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 12 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_msg_thread_marks (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_msg_thread_marks_author ON cotton_msg_thread_marks (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX uq_cotton_msg_thread_marks_copy ON cotton_msg_thread_marks (workspace_id, database_id, thread_id)" ], "full_text": [], "triggers": [] } ] }, "thread_member": { "engine": "messages", "tables": [ { "name": "cotton_msg_thread_participants", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 1 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 2 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n contact_id TEXT", "position": 3 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n display_name TEXT", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "role", "type": "TEXT", "default": "'member'", "nullable": false, "primary_key": false, "declaration": "\n role TEXT NOT NULL DEFAULT 'member'", "position": 6 }, { "name": "left_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n left_at TEXT", "position": 7 }, { "name": "is_self", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n is_self INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 9 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 10 } ], "constraints": [ { "declaration": "\n CHECK (role IN ('admin', 'member'))", "position": 11 }, { "declaration": "\n CHECK ((is_self = 1) OR (contact_id IS NOT NULL) OR (NULLIF(trim(COALESCE(display_name, '')), '') IS NOT NULL))", "position": 12 }, { "declaration": "\n FOREIGN KEY (contact_id) REFERENCES cotton_msg_contacts(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 14 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE \"cotton_msg_thread_participants\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_thread_participants_contact ON cotton_msg_thread_participants (contact_id)", "CREATE INDEX idx_cotton_msg_thread_participants_workspace ON cotton_msg_thread_participants (workspace_id)", "CREATE INDEX idx_cotton_msg_thread_participants_thread_label ON cotton_msg_thread_participants (thread_id, display_name)", "CREATE INDEX idx_cotton_msg_thread_participants_thread_contact ON cotton_msg_thread_participants (thread_id, contact_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_thread_participants_author ON cotton_msg_thread_participants (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "todo": { "engine": "todos", "tables": [ { "name": "cotton_todos", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 1 }, { "name": "notes", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n notes TEXT", "position": 2 }, { "name": "label", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n label TEXT", "position": 3 }, { "name": "status", "type": "TEXT", "default": "'open'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'open'", "position": 4 }, { "name": "due_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n due_at TEXT", "position": 5 }, { "name": "snoozed_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n snoozed_until TEXT", "position": 6 }, { "name": "priority", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n priority INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "completed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n completed_at TEXT", "position": 8 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "recurrence_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n recurrence_id TEXT", "position": 12 }, { "name": "occurrence_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n occurrence_at TEXT", "position": 13 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 14 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 15 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 16 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 17 } ], "constraints": [ { "declaration": "\n UNIQUE (recurrence_id, occurrence_at)", "position": 18 }, { "declaration": "\n CHECK (status IN ('open', 'done', 'dropped', 'missed'))", "position": 19 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 20 } ], "prefix": "CREATE TABLE cotton_todos (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_todos_open ON cotton_todos (workspace_id) WHERE status = 'open' AND trashed_at IS NULL", "CREATE INDEX idx_cotton_todos_recurrence ON cotton_todos (recurrence_id) WHERE recurrence_id IS NOT NULL", "CREATE INDEX idx_cotton_todos_workspace ON cotton_todos (workspace_id)", "CREATE INDEX idx_cotton_todos_workspace_due ON cotton_todos (workspace_id, due_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_todos_author ON cotton_todos (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_todos USING fts5(\n title, notes, content = 'cotton_todos', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_todos_ai AFTER INSERT ON cotton_todos WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) BEGIN\n INSERT INTO fts_todos (rowid, title, notes) VALUES (new.rowid, new.title, new.notes);\n END", "CREATE TRIGGER fts_todos_ad AFTER DELETE ON cotton_todos WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) BEGIN\n INSERT INTO fts_todos (fts_todos, rowid, title, notes) VALUES ('delete', old.rowid, old.title, old.notes);\n END", "CREATE TRIGGER fts_todos_au AFTER UPDATE OF title, notes ON cotton_todos\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) AND (new.title IS NOT old.title OR new.notes IS NOT old.notes) BEGIN\n INSERT INTO fts_todos (fts_todos, rowid, title, notes) VALUES ('delete', old.rowid, old.title, old.notes);\n INSERT INTO fts_todos (rowid, title, notes) VALUES (new.rowid, new.title, new.notes);\n END" ] } ] }, "todo_recurrence": { "engine": "todos", "tables": [ { "name": "cotton_todo_recurrences", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "title", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n title TEXT NOT NULL", "position": 1 }, { "name": "notes", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n notes TEXT", "position": 2 }, { "name": "priority", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n priority INTEGER NOT NULL DEFAULT 0", "position": 3 }, { "name": "rrule", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n rrule TEXT NOT NULL", "position": 4 }, { "name": "dtstart", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n dtstart TEXT NOT NULL", "position": 5 }, { "name": "paused", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n paused INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "materialized_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n materialized_until TEXT", "position": 7 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 15 } ], "prefix": "CREATE TABLE cotton_todo_recurrences (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_todo_recurrences_workspace ON cotton_todo_recurrences (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_todo_recurrences_author ON cotton_todo_recurrences (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "toolkit": { "engine": "toolkits", "tables": [] }, "transaction": { "engine": "money", "tables": [ { "name": "cotton_money_transactions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "occurred_on", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n occurred_on TEXT NOT NULL", "position": 2 }, { "name": "description", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n description TEXT NOT NULL DEFAULT ''", "position": 3 }, { "name": "payee_text", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n payee_text TEXT", "position": 4 }, { "name": "account_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n account_id TEXT", "position": 5 }, { "name": "counterparty_person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n counterparty_person_id TEXT", "position": 6 }, { "name": "amount_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n amount_minor INTEGER", "position": 7 }, { "name": "amount_known", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n amount_known INTEGER NOT NULL DEFAULT 1 CHECK (amount_known IN (0,1))", "position": 8 }, { "name": "direction", "type": "TEXT", "default": "'out'", "nullable": false, "primary_key": false, "declaration": "\n direction TEXT NOT NULL DEFAULT 'out' CHECK (direction IN ('in','out'))", "position": 9 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n currency TEXT", "position": 10 }, { "name": "for_period", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n for_period TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "status", "type": "TEXT", "default": "'actual'", "nullable": false, "primary_key": false, "declaration": "\n status TEXT NOT NULL DEFAULT 'actual' CHECK (status IN ('actual','expected'))", "position": 12 }, { "name": "certainty", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n certainty TEXT CHECK (certainty IS NULL OR certainty IN ('fixed','expected','estimate'))", "position": 13 }, { "name": "repeat", "type": "TEXT", "default": "'none'", "nullable": false, "primary_key": false, "declaration": "\n repeat TEXT NOT NULL DEFAULT 'none' CHECK (repeat IN ('none','monthly'))", "position": 14 }, { "name": "repeat_day", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n repeat_day INTEGER CHECK (repeat_day IS NULL OR repeat_day BETWEEN 1 AND 31)", "position": 15 }, { "name": "between_us", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n between_us INTEGER NOT NULL DEFAULT 0 CHECK (between_us IN (0,1))", "position": 16 }, { "name": "moves_money", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n moves_money INTEGER NOT NULL DEFAULT 1 CHECK (moves_money IN (0,1))", "position": 17 }, { "name": "tag", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n tag TEXT", "position": 18 }, { "name": "transfer_of", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n transfer_of TEXT", "position": 19 }, { "name": "source", "type": "TEXT", "default": "'manual'", "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL DEFAULT 'manual'", "position": 20 }, { "name": "external_hash", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_hash TEXT", "position": 21 }, { "name": "notes", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n notes TEXT", "position": 22 }, { "name": "settles_transaction_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n settles_transaction_id TEXT", "position": 23 }, { "name": "due_date", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n due_date TEXT", "position": 24 }, { "name": "source_inbox_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n source_inbox_id TEXT", "position": 25 }, { "name": "created_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n created_by TEXT", "position": 26 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 27 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 28 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 29 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 30 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 31 } ], "constraints": [ { "declaration": "\n CHECK ((settles_transaction_id IS NULL) OR (settles_transaction_id <> id))", "position": 32 }, { "declaration": "\n CHECK (source IN ('capture', 'manual', 'import', 'system', 'schedule', 'migration', 'statement', 'external'))", "position": 33 }, { "declaration": "\n FOREIGN KEY (account_id) REFERENCES cotton_money_accounts(id)", "position": 34 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 35 } ], "prefix": "CREATE TABLE \"cotton_money_transactions\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_money_transactions_balance ON cotton_money_transactions (workspace_id,account_id,currency,occurred_on,CASE WHEN direction='in' THEN amount_minor ELSE -amount_minor END,direction,amount_minor,status,amount_known,moves_money,trashed_at) WHERE status='actual' AND amount_known=1 AND moves_money=1 AND trashed_at IS NULL", "CREATE INDEX idx_cotton_money_transactions_glance ON cotton_money_transactions (workspace_id,trashed_at,between_us,status,direction,currency,amount_minor)", "CREATE INDEX idx_cotton_money_transactions_due ON cotton_money_transactions (due_date) WHERE due_date IS NOT NULL", "CREATE INDEX idx_cotton_money_transactions_account ON cotton_money_transactions (account_id) WHERE account_id IS NOT NULL", "CREATE INDEX idx_cotton_money_transactions_expected ON cotton_money_transactions (workspace_id,occurred_on,id,due_date,currency,direction,amount_minor,trashed_at) WHERE status='expected'", "CREATE INDEX idx_cotton_money_transactions_person ON cotton_money_transactions (counterparty_person_id) WHERE counterparty_person_id IS NOT NULL", "CREATE INDEX idx_cotton_money_transactions_owed ON cotton_money_transactions (workspace_id,status,trashed_at,counterparty_person_id,occurred_on DESC,updated_at DESC,id,direction,amount_minor,currency,description) WHERE counterparty_person_id IS NOT NULL", "CREATE INDEX idx_cotton_money_transactions_settles ON cotton_money_transactions (settles_transaction_id) WHERE settles_transaction_id IS NOT NULL", "CREATE INDEX idx_cotton_money_transactions_workspace ON cotton_money_transactions (workspace_id)", "CREATE INDEX idx_cotton_money_transactions_workspace_date ON cotton_money_transactions (workspace_id, occurred_on DESC)", "CREATE UNIQUE INDEX uq_cotton_money_transactions_external_hash ON cotton_money_transactions (workspace_id, external_hash) WHERE external_hash IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_money_transactions_author ON cotton_money_transactions (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ] }, "video": { "engine": "media", "tables": [ { "name": "cotton_videos", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n key TEXT NOT NULL", "position": 2 }, { "name": "sha256", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n sha256 TEXT NOT NULL", "position": 3 }, { "name": "content_type", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n content_type TEXT NOT NULL", "position": 4 }, { "name": "size_bytes", "type": "INTEGER", "default": null, "nullable": false, "primary_key": false, "declaration": "\n size_bytes INTEGER NOT NULL", "position": 5 }, { "name": "width", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n width INTEGER", "position": 6 }, { "name": "height", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n height INTEGER", "position": 7 }, { "name": "duration_ms", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n duration_ms INTEGER", "position": 8 }, { "name": "taken_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n taken_at TEXT NOT NULL", "position": 9 }, { "name": "preview", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n preview TEXT", "position": 10 }, { "name": "poster_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n poster_key TEXT", "position": 11 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 12 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 13 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 14 }, { "name": "summary_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_at TEXT", "position": 15 }, { "name": "review_note", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_note TEXT", "position": 16 }, { "name": "review_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_by TEXT", "position": 17 }, { "name": "review_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n review_at TEXT", "position": 18 }, { "name": "taken_offset", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n taken_offset INTEGER", "position": 19 }, { "name": "latitude", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n latitude REAL", "position": 20 }, { "name": "longitude", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n longitude REAL", "position": 21 }, { "name": "place_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_name TEXT", "position": 22 }, { "name": "place_city", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_city TEXT", "position": 23 }, { "name": "place_region", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_region TEXT", "position": 24 }, { "name": "place_country", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n place_country TEXT", "position": 25 }, { "name": "camera_make", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n camera_make TEXT", "position": 26 }, { "name": "camera_model", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n camera_model TEXT", "position": 27 }, { "name": "orientation", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n orientation INTEGER", "position": 28 }, { "name": "favourite", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n favourite INTEGER NOT NULL DEFAULT 0", "position": 29 }, { "name": "subtypes", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n subtypes TEXT NOT NULL DEFAULT '[]'", "position": 30 }, { "name": "original_filename", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n original_filename TEXT", "position": 31 }, { "name": "aesthetic_score", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n aesthetic_score REAL", "position": 32 }, { "name": "curation_score", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n curation_score REAL", "position": 33 }, { "name": "labels", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n labels TEXT NOT NULL DEFAULT '[]'", "position": 34 }, { "name": "phash", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n phash TEXT", "position": 35 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 36 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 37 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 38 }, { "name": "origin_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)", "position": 39 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 40 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 41 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, sha256)", "position": 42 }, { "declaration": "\n CHECK (id = 'video:' || sha256)", "position": 43 }, { "declaration": "\n CHECK (sha256 NOT GLOB '*[^0-9a-f]*' AND length(sha256) = 64)", "position": 44 }, { "declaration": "\n CHECK (size_bytes >= 0)", "position": 45 }, { "declaration": "\n CHECK (width IS NULL OR width > 0)", "position": 46 }, { "declaration": "\n CHECK (height IS NULL OR height > 0)", "position": 47 }, { "declaration": "\n CHECK (caption IS NULL OR length(caption) <= 500)", "position": 48 }, { "declaration": "\n CHECK (review_note IS NULL OR (length(trim(review_note)) > 0 AND length(review_note) <= 280))", "position": 49 }, { "declaration": "\n CHECK ((summary IS NULL) = (summary_at IS NULL))", "position": 50 }, { "declaration": "\n CHECK ((review_note IS NULL) = (review_at IS NULL))", "position": 51 }, { "declaration": "\n CHECK ((latitude IS NULL) = (longitude IS NULL))", "position": 52 }, { "declaration": "\n CHECK (latitude IS NULL OR (latitude >= -90 AND latitude <= 90))", "position": 53 }, { "declaration": "\n CHECK (longitude IS NULL OR (longitude >= -180 AND longitude <= 180))", "position": 54 }, { "declaration": "\n CHECK (orientation IS NULL OR (orientation >= 1 AND orientation <= 8))", "position": 55 }, { "declaration": "\n CHECK (taken_offset IS NULL OR (taken_offset >= -86400 AND taken_offset <= 86400))", "position": 56 }, { "declaration": "\n CHECK (favourite IN (0, 1))", "position": 57 }, { "declaration": "\n CHECK (json_type(subtypes) = 'array')", "position": 58 }, { "declaration": "\n CHECK (json_type(labels) = 'array')", "position": 59 }, { "declaration": "\n CHECK (aesthetic_score IS NULL OR (aesthetic_score >= -1 AND aesthetic_score <= 1))", "position": 60 }, { "declaration": "\n CHECK (curation_score IS NULL OR (curation_score >= -1 AND curation_score <= 1))", "position": 61 }, { "declaration": "\n CHECK (phash IS NULL OR (length(phash) = 16 AND phash NOT GLOB '*[^0-9a-f]*'))", "position": 62 }, { "declaration": "\n CHECK (duration_ms IS NULL OR duration_ms >= 0)", "position": 63 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 64 } ], "prefix": "CREATE TABLE \"cotton_videos\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_videos_taken ON cotton_videos (workspace_id, taken_at DESC)", "CREATE INDEX idx_cotton_videos_review ON cotton_videos (workspace_id, review_at) WHERE review_note IS NOT NULL", "CREATE INDEX idx_cotton_videos_undescribed ON cotton_videos (workspace_id, taken_at DESC) WHERE summary IS NULL", "CREATE INDEX idx_cotton_videos_place ON cotton_videos (workspace_id, place_city)", "CREATE INDEX idx_cotton_videos_favourite ON cotton_videos (workspace_id, taken_at DESC) WHERE favourite = 1", "CREATE INDEX idx_cotton_videos_phash ON cotton_videos (workspace_id, phash) WHERE phash IS NOT NULL", "CREATE INDEX idx_cotton_videos_origin ON cotton_videos (origin_handle) WHERE origin_handle IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_videos_author ON cotton_videos (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_videos USING fts5(\n caption, summary, content = 'cotton_videos', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_videos_ai AFTER INSERT ON cotton_videos WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_videos'), 0) BEGIN\n INSERT INTO fts_videos (rowid, caption, summary) VALUES (new.rowid, new.caption, new.summary);\n END", "CREATE TRIGGER fts_videos_ad AFTER DELETE ON cotton_videos WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_videos'), 0) BEGIN\n INSERT INTO fts_videos (fts_videos, rowid, caption, summary) VALUES ('delete', old.rowid, old.caption, old.summary);\n END", "CREATE TRIGGER fts_videos_au AFTER UPDATE OF caption, summary ON cotton_videos\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_videos'), 0) AND (new.caption IS NOT old.caption OR new.summary IS NOT old.summary) BEGIN\n INSERT INTO fts_videos (fts_videos, rowid, caption, summary) VALUES ('delete', old.rowid, old.caption, old.summary);\n INSERT INTO fts_videos (rowid, caption, summary) VALUES (new.rowid, new.caption, new.summary);\n END" ] } ] }, "voice_word": { "engine": "dictation", "tables": [] } }