-- Fix IsSystemDefined flag for Job Priorities
-- Only "NORMAL" should be system-defined, the rest should be editable

PRINT 'Fixing Job Priority system-defined flags...';

UPDATE JobPriorityLookups
SET IsSystemDefined = 0
WHERE PriorityCode IN ('LOW', 'HIGH', 'URGENT', 'RUSH');

PRINT 'Fixed. Only NORMAL priority is now system-defined.';

-- Verify
SELECT
    PriorityCode,
    DisplayName,
    IsSystemDefined,
    CASE WHEN IsSystemDefined = 1 THEN 'Protected' ELSE 'Editable' END AS Status
FROM JobPriorityLookups
WHERE IsDeleted = 0
ORDER BY DisplayOrder;
