-- Fix Company Admin Permissions
-- This script updates all existing Company Admins to have all permissions

-- Update all users with CompanyRole = 'CompanyAdmin' to have all permissions
UPDATE AspNetUsers
SET
    CanManageJobs = 1,
    CanManageInventory = 1,
    CanManageCustomers = 1,
    CanCreateQuotes = 1,
    CanApproveQuotes = 1,
    CanManageCalendar = 1,
    CanViewCalendar = 1,
    CanManageProducts = 1,
    CanViewProducts = 1,
    CanManageEquipment = 1,
    CanManageSuppliers = 1,
    CanManageMaintenance = 1
WHERE CompanyRole = 'CompanyAdmin';

-- Show how many users were updated
SELECT
    Id,
    Email,
    FirstName,
    LastName,
    CompanyRole,
    CanManageCalendar,
    CanManageProducts,
    CanManageEquipment
FROM AspNetUsers
WHERE CompanyRole = 'CompanyAdmin';
