ALTER TABLE subgroups
    DROP CONSTRAINT IF EXISTS subgroups_group_id_name_key;

CREATE UNIQUE INDEX IF NOT EXISTS ux_subgroups_active_group_name
    ON subgroups (group_id, lower(name))
    WHERE status <> 'ARCHIVED';
