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

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

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

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

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

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