Files
geo/server/migrations/20260511110000_generation_task_terminal_repair_indexes.up.sql
T

14 lines
556 B
SQL
Raw Normal View History

CREATE INDEX IF NOT EXISTS idx_generation_tasks_recent_terminal_state_repair
ON generation_tasks(updated_at DESC, id DESC)
WHERE article_id IS NOT NULL
AND status IN ('failed', 'completed');
CREATE INDEX IF NOT EXISTS idx_generation_tasks_article_latest_state_repair
ON generation_tasks(article_id, tenant_id, created_at DESC, id DESC)
WHERE article_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_articles_generating_state_repair
ON articles(id, tenant_id)
WHERE generate_status = 'generating'
AND deleted_at IS NULL;