-- Benutzerverwaltung: Kontostatus, Sitzungsübersicht, persistente Login-Begrenzung, -- Raumrolle "Leser" und Rollen in Einladungen. Bestehende Zeilen bleiben gültig. ALTER TABLE auth_accounts ADD COLUMN must_change_password boolean NOT NULL DEFAULT false, ADD COLUMN password_changed_at timestamptz, ADD COLUMN last_login_at timestamptz, ADD COLUMN disabled_at timestamptz, ADD COLUMN disabled_by uuid REFERENCES auth_accounts (id); ALTER TABLE auth_sessions ADD COLUMN last_seen_at timestamptz, ADD COLUMN label text, ADD CONSTRAINT auth_sessions_label_len CHECK (label IS NULL OR char_length(label) <= 80); -- Der Bucket ist ein Hash aus Adresse und E-Mail. Die Roh-E-Mail wird nie gespeichert. CREATE TABLE auth_login_attempts ( bucket text NOT NULL, attempted_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX auth_login_attempts_bucket ON auth_login_attempts (bucket, attempted_at); ALTER TABLE room_memberships DROP CONSTRAINT room_memberships_role; ALTER TABLE room_memberships ADD CONSTRAINT room_memberships_role CHECK (role IN ('member', 'manager', 'reader')); ALTER TABLE auth_invitations ADD COLUMN role text NOT NULL DEFAULT 'member', ADD COLUMN revoked_at timestamptz, ADD CONSTRAINT auth_invitations_role CHECK (role IN ('member', 'manager', 'reader'));