CREATE UNIQUE INDEX IF NOT EXISTS providers_single_global_default_idx
    ON gateway.providers ((1))
    WHERE tenant_id IS NULL AND enabled AND config @> '{"default": true}'::jsonb;

COMMENT ON INDEX gateway.providers_single_global_default_idx IS
    'At most one enabled global provider may be the explicit runtime default.';
