-- Drop the existing unique constraint
ALTER TABLE administration.users DROP CONSTRAINT IF EXISTS UC_KeycloakId;

-- Add a partial unique index to allow guid-0 duplicates
CREATE UNIQUE INDEX IF NOT EXISTS idx_unique_keycloakid
    ON administration.users (KeycloakId)
    WHERE KeycloakId != '00000000-0000-0000-0000-000000000000';