-- API-Schnittstelle je Verein und benannte Schlüssel mit Objekt- und Sichtbarkeitsrechten. -- Bestehende Schlüssel behalten den Abruf von Übungen über alle Sichtbarkeiten, damit die Testschlüssel weiter gelten. ALTER TABLE clubs ADD COLUMN IF NOT EXISTS distribution_api_enabled BOOLEAN NOT NULL DEFAULT false; ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS label TEXT; ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS objects TEXT[] NOT NULL DEFAULT ARRAY['exercise']::text[]; ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS visibilities TEXT[] NOT NULL DEFAULT ARRAY['official', 'club', 'private']::text[]; ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS context_kind TEXT NOT NULL DEFAULT 'platform'; ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS context_club_id INT REFERENCES clubs (id); ALTER TABLE distribution_keys ADD COLUMN IF NOT EXISTS context_profile_id INT REFERENCES profiles (id); UPDATE distribution_keys SET label = key_prefix WHERE label IS NULL OR btrim(label) = '';