BEGIN; UPDATE golden_steps SET status = 'IN_PROGRESS', completed_at = NULL, updated_at = now() WHERE action_type = 'METRIC' AND status = 'COMPLETED' AND ( current_value IS NULL OR target IS NULL OR metric_direction IS NULL OR (metric_direction = 'INCREASE' AND current_value < target) OR (metric_direction = 'DECREASE' AND current_value > target) ); INSERT INTO schema_migrations(version) VALUES (6); COMMIT;