-- Ensure auto-generated item group numbers stay unique when multiple users create rows concurrently.
CREATE UNIQUE INDEX IF NOT EXISTS ux_item_groups_group_number
ON item_groups ((NULLIF(TRIM(raw->>'groupNumber'), '')))
WHERE NULLIF(TRIM(raw->>'groupNumber'), '') IS NOT NULL;
