CREATE TABLE IF NOT EXISTS agents (
    id TEXT PRIMARY KEY,
    name TEXT NOT NULL,
    role TEXT NOT NULL,
    tool TEXT NOT NULL,
    custom_prompt TEXT NOT NULL DEFAULT '',
    created_at TEXT NOT NULL DEFAULT (datetime('now')),
    updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);

ALTER TABLE watched_trackers ADD COLUMN analyst_agent_id TEXT;
ALTER TABLE watched_trackers ADD COLUMN developer_agent_id TEXT;
ALTER TABLE watched_trackers ADD COLUMN status TEXT NOT NULL DEFAULT 'valid';

UPDATE watched_trackers
SET status = 'invalid'
WHERE analyst_agent_id IS NULL OR developer_agent_id IS NULL;
