-- easyai:migration:no-transaction
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_gateway_tasks_admin_created
  ON gateway_tasks(created_at DESC, id DESC);

-- easyai:migration:statement
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_gateway_tasks_admin_status_created
  ON gateway_tasks(status, created_at DESC, id DESC);

-- easyai:migration:statement
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_gateway_tasks_admin_user_created
  ON gateway_tasks(gateway_user_id, created_at DESC, id DESC)
  WHERE gateway_user_id IS NOT NULL;

-- easyai:migration:statement
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_gateway_tasks_admin_tenant_created
  ON gateway_tasks(gateway_tenant_id, created_at DESC, id DESC)
  WHERE gateway_tenant_id IS NOT NULL;

-- easyai:migration:statement
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_gateway_task_attempts_admin_platform_task
  ON gateway_task_attempts(platform_id, task_id)
  WHERE platform_id IS NOT NULL;
