CREATE TABLE oauth_scope_preference ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), did TEXT NOT NULL REFERENCES users(did) ON DELETE CASCADE, client_id TEXT NOT NULL, scope TEXT NOT NULL, granted BOOLEAN NOT NULL DEFAULT TRUE, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), UNIQUE(did, client_id, scope) ); CREATE INDEX idx_oauth_scope_pref_lookup ON oauth_scope_preference(did, client_id);