-- Slice 8-UX · Unlock perms (Executive + Administrator)
INSERT INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on)
SELECT g.c0d, 'Tenders', a.act, 0, NOW()
FROM (SELECT 'unlockContractTermsAj' AS act UNION ALL SELECT 'relockContractTermsAj') a
CROSS JOIN user_groups g
WHERE g.user_group_name IN ('Executive','Administrator')
  AND NOT EXISTS (
    SELECT 1 FROM user_groups_perms p
     WHERE p.user_group_id = g.c0d AND p.controller_allowed = 'Tenders' AND p.action_allowed = a.act
  );
