-- ComfyUI 数据库表结构回滚脚本
-- 迁移版本: 033

-- 删除视图
DROP VIEW IF EXISTS comfyui_execution_summary;
DROP VIEW IF EXISTS comfyui_execution_stats;

-- 删除触发器
DROP TRIGGER IF EXISTS update_comfyui_workflows_updated_at;
DROP TRIGGER IF EXISTS update_comfyui_templates_updated_at;
DROP TRIGGER IF EXISTS update_comfyui_configs_updated_at;

-- 删除索引
DROP INDEX IF EXISTS idx_comfyui_workflows_name;
DROP INDEX IF EXISTS idx_comfyui_workflows_category;
DROP INDEX IF EXISTS idx_comfyui_workflows_created_at;
DROP INDEX IF EXISTS idx_comfyui_workflows_enabled;

DROP INDEX IF EXISTS idx_comfyui_templates_name;
DROP INDEX IF EXISTS idx_comfyui_templates_category;
DROP INDEX IF EXISTS idx_comfyui_templates_author;
DROP INDEX IF EXISTS idx_comfyui_templates_created_at;
DROP INDEX IF EXISTS idx_comfyui_templates_enabled;

DROP INDEX IF EXISTS idx_comfyui_executions_workflow_id;
DROP INDEX IF EXISTS idx_comfyui_executions_template_id;
DROP INDEX IF EXISTS idx_comfyui_executions_prompt_id;
DROP INDEX IF EXISTS idx_comfyui_executions_status;
DROP INDEX IF EXISTS idx_comfyui_executions_created_at;
DROP INDEX IF EXISTS idx_comfyui_executions_completed_at;
DROP INDEX IF EXISTS idx_comfyui_executions_client_id;

DROP INDEX IF EXISTS idx_comfyui_queue_history_snapshot_time;

-- 删除表
DROP TABLE IF EXISTS comfyui_configs;
DROP TABLE IF EXISTS comfyui_queue_history;
DROP TABLE IF EXISTS comfyui_executions;
DROP TABLE IF EXISTS comfyui_templates;
DROP TABLE IF EXISTS comfyui_workflows;
