-- Motorboy BusOps V1.5.0
INSERT INTO permissions(code,description)
VALUES('report.view_all_branches','View reports across all operator branches')
ON DUPLICATE KEY UPDATE description=VALUES(description);

INSERT IGNORE INTO role_permissions(role_id,permission_id)
SELECT r.id,p.id
FROM roles r
JOIN permissions p ON p.code='report.view_all_branches'
WHERE r.code IN ('operator_admin','central_manager');

INSERT INTO system_settings(setting_key,setting_value)
VALUES('installed_version','1.5.0')
ON DUPLICATE KEY UPDATE setting_value=VALUES(setting_value);
