CREATE INDEX IF NOT EXISTS idx_senlin_agent_projects_search
ON senlin_agent_projects
USING gin (to_tsvector('simple', coalesce(name, '') || ' ' || coalesce(description, '')));

CREATE INDEX IF NOT EXISTS idx_senlin_agent_notes_search
ON senlin_agent_notes
USING gin (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(markdown, '')));

CREATE INDEX IF NOT EXISTS idx_senlin_agent_sources_search
ON senlin_agent_sources
USING gin (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(url, '') || ' ' || coalesce(content_text, '')));

CREATE INDEX IF NOT EXISTS idx_senlin_agent_inbox_items_search
ON senlin_agent_inbox_items
USING gin (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(body, '')));

CREATE INDEX IF NOT EXISTS idx_senlin_agent_tasks_search
ON senlin_agent_tasks
USING gin (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(description, '')));

CREATE INDEX IF NOT EXISTS idx_senlin_agent_ai_sessions_search
ON senlin_agent_ai_sessions
USING gin (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(context, '')));
