-- v4.19 — Grant inventory.create permission to existing counter employees
-- so they can create items and record purchase entries.
INSERT INTO employee_permissions (employee_id, permission)
SELECT e.id, 'inventory.create'
FROM employees e
WHERE e.role = 'counter'
  AND e.is_active = true
  AND NOT EXISTS (
      SELECT 1 FROM employee_permissions ep
      WHERE ep.employee_id = e.id AND ep.permission = 'inventory.create'
  );
