-- ====================================================================
-- Reports module permissions (2026-09-23)
--   • reports:read   — open Admin → Reports (the live store report)
--   • reports:export — download the report as a PDF
--   Both are granted to super_admin. Give them to other roles from
--   Employees → Roles if they should see the report.
-- Plain statements only, safe to run more than once.
-- ====================================================================

SET NAMES utf8mb4;

INSERT IGNORE INTO `permissions` (`id`, `name`, `module`, `action`) VALUES
  (UUID(), 'reports:read', 'reports', 'read'),
  (UUID(), 'reports:export', 'reports', 'export');

INSERT IGNORE INTO `role_permissions` (`id`, `role_id`, `permission_id`)
SELECT UUID(), r.id, p.id
FROM `roles` r
JOIN `permissions` p ON p.name IN ('reports:read', 'reports:export')
WHERE r.name = 'super_admin';
