-- SDLC Pipeline Definition
-- Pipeline: sdlc_full - 完整SDLC产线 (28 steps)
-- Run against the 'pipeline' database

-- Insert pipeline_steps records
INSERT INTO pipeline_steps (id, pipeline_id, step_name, step_type, display_name, step_order, step_config, created_at)
VALUES
-- Phase 1: Requirements
('step_001', 'sdlc_full', 'requirement_gathering', 'requirement_gathering', '需求采集', 1, '{"deps":[]}', NOW()),
('step_002', 'sdlc_full', 'requirement_review', 'requirement_review', '需求评审', 2, '{"deps":["requirement_gathering"]}', NOW()),

-- Phase 2: Design (parallel-safe)
('step_003', 'sdlc_full', 'table_design', 'table_design', '数据表设计', 3, '{"deps":["requirement_review"]}', NOW()),
('step_004', 'sdlc_full', 'crud_design', 'crud_design', 'CRUD设计', 4, '{"deps":["requirement_review"]}', NOW()),
('step_005', 'sdlc_full', 'api_design', 'api_design', 'API设计', 5, '{"deps":["requirement_review"]}', NOW()),
('step_006', 'sdlc_full', 'design_review', 'design_review', '设计评审', 6, '{"deps":["table_design","crud_design","api_design"]}', NOW()),

-- Phase 3: Development
('step_007', 'sdlc_full', 'code_generate', 'code_generate', '代码生成', 7, '{"deps":["design_review"]}', NOW()),
('step_008', 'sdlc_full', 'code_compliance_check', 'code_compliance_check', '规范检查', 8, '{"deps":["code_generate"]}', NOW()),
('step_009', 'sdlc_full', 'code_auto_fix', 'code_auto_fix', '自动修复', 9, '{"deps":["code_compliance_check"]}', NOW()),
('step_010', 'sdlc_full', 'code_review', 'code_review', '代码审查', 10, '{"deps":["code_auto_fix"]}', NOW()),
('step_011', 'sdlc_full', 'code_fix', 'code_fix', '代码修复', 11, '{"deps":["code_review"]}', NOW()),

-- Phase 4: Testing
('step_012', 'sdlc_full', 'test_plan_create', 'test_plan_create', '测试方案', 12, '{"deps":["code_review"]}', NOW()),
('step_013', 'sdlc_full', 'test_case_generate', 'test_case_generate', '用例生成', 13, '{"deps":["test_plan_create"]}', NOW()),
('step_014', 'sdlc_full', 'functional_test', 'functional_test', '功能测试', 14, '{"deps":["test_case_generate"]}', NOW()),
('step_015', 'sdlc_full', 'performance_test', 'performance_test', '性能测试', 15, '{"deps":["test_case_generate"]}', NOW()),
('step_016', 'sdlc_full', 'bug_report', 'bug_report', 'Bug报告', 16, '{"deps":["functional_test","performance_test"]}', NOW()),
('step_017', 'sdlc_full', 'bug_fix', 'bug_fix', 'Bug修复', 17, '{"deps":["bug_report"]}', NOW()),
('step_018', 'sdlc_full', 'bug_verify', 'bug_verify', 'Bug验证', 18, '{"deps":["bug_fix"]}', NOW()),
('step_019', 'sdlc_full', 'acceptance_test', 'acceptance_test', '验收测试', 19, '{"deps":["bug_verify"]}', NOW()),

-- Phase 5: Deployment
('step_020', 'sdlc_full', 'deploy_env_collect', 'deploy_env_collect', '环境配置', 20, '{"deps":["acceptance_test"]}', NOW()),
('step_021', 'sdlc_full', 'deploy_test', 'deploy_test', '测试部署', 21, '{"deps":["deploy_env_collect"]}', NOW()),
('step_022', 'sdlc_full', 'deploy_test_verify', 'deploy_test_verify', '测试验证', 22, '{"deps":["deploy_test"]}', NOW()),
('step_023', 'sdlc_full', 'deploy_test_approve', 'deploy_test_approve', '部署审批', 23, '{"deps":["deploy_test_verify"]}', NOW()),
('step_024', 'sdlc_full', 'deploy_production', 'deploy_production', '生产部署', 24, '{"deps":["deploy_test_approve"]}', NOW()),
('step_025', 'sdlc_full', 'deploy_production_verify', 'deploy_production_verify', '生产验证', 25, '{"deps":["deploy_production"]}', NOW()),

-- Phase 6: Operations
('step_026', 'sdlc_full', 'monitor', 'monitor', '运行监控', 26, '{"deps":["deploy_production_verify"]}', NOW()),
('step_027', 'sdlc_full', 'incident_response', 'incident_response', '故障处理', 27, '{"deps":["monitor"]}', NOW()),

-- Phase 7: Upgrade
('step_028', 'sdlc_full', 'upgrade_plan', 'upgrade_plan', '升级规划', 28, '{"deps":["monitor"]}', NOW())

ON DUPLICATE KEY UPDATE
  step_name = VALUES(step_name),
  step_type = VALUES(step_type),
  display_name = VALUES(display_name),
  step_order = VALUES(step_order),
  step_config = VALUES(step_config);
