-- Add Cases tab permissions for lab organizations

INSERT INTO "features" ("id", "name", "description", "organizationTypeId")
VALUES (gen_random_uuid(), 'Cases', 'Lab cases inbox', NULL)
ON CONFLICT ("name") DO NOTHING;

INSERT INTO "permissions" ("id", "name", "description", "featureId")
SELECT gen_random_uuid(), v.name, NULL, f.id
FROM (VALUES
  ('TAB_CASES_READ'),
  ('TAB_CASES_EDIT')
) AS v(name)
CROSS JOIN "features" f
WHERE f.name = 'Cases'
ON CONFLICT ("name") DO NOTHING;
