-- DentalCare v0.5.6: preferred-schedule doctor filtering, reschedule notes, schedule bypass, print-route repair
INSERT INTO `{{prefix}}permissions` (`code`,`name`,`module_group`,`description`)
VALUES ('appointments.schedule_bypass','Bypass schedule controls','Schedule','Allow an authorized administrator to override published availability or conflicts with a mandatory reason')
ON DUPLICATE KEY UPDATE `name`=VALUES(`name`),`description`=VALUES(`description`);

INSERT IGNORE INTO `{{prefix}}role_permissions` (`role_id`,`permission_id`,`allowed`)
SELECT r.id,p.id,1
FROM `{{prefix}}roles` r
JOIN `{{prefix}}permissions` p ON p.code='appointments.schedule_bypass'
WHERE r.code IN ('super_admin','clinic_admin');
