-- Add Work Order Raised to Workshop In Progress transition
-- This migration adds the new transition to the maintenance_stages and stage_transitions tables

-- First ensure the stages exist
INSERT IGNORE INTO maintenance_stages (stage_name, stage_order, is_terminal, is_active) VALUES
('Work Order Raised', 30, 0, 1),
('Workshop In Progress', 80, 0, 1);

-- Add the new transition
INSERT IGNORE INTO stage_transitions (from_stage_id, to_stage_id, is_active)
SELECT f.id, t.id, 1 
FROM maintenance_stages f 
CROSS JOIN maintenance_stages t 
WHERE f.stage_name = 'Work Order Raised' 
AND t.stage_name = 'Workshop In Progress';