-- 0002_todos.sql — Phase 2 set search_path to ordinarthur_os, public; create table if not exists ordinarthur_os.todos ( id uuid primary key default gen_random_uuid(), title text not null, description text, status text not null default 'inbox' check (status in ('inbox', 'todo', 'doing', 'done', 'archived')), priority smallint check (priority between 0 and 3), due_at timestamptz, tags text[] not null default '{}', project_id uuid, checklist jsonb not null default '[]'::jsonb, energy text check (energy in ('low', 'med', 'high')), context text, recurrence text, ticket_url text, verification_steps text[] not null default '{}', ai_enriched boolean not null default false, created_at timestamptz not null default now(), completed_at timestamptz ); create index if not exists todos_status_idx on ordinarthur_os.todos(status); create index if not exists todos_due_at_idx on ordinarthur_os.todos(due_at); create index if not exists todos_tags_gin on ordinarthur_os.todos using gin (tags);