16 lines
828 B
SQL
16 lines
828 B
SQL
-- Einstellungen je Konto. Ein Mitarbeiter erbt den Wert seines Hauptnutzers und kann ihn ändern,
|
|
-- solange der Hauptnutzer die Einstellung nicht für das Team verbindlich gesetzt hat (team_mode).
|
|
-- Erlaubte Werte, Standard und Verbindlichkeit je Schlüssel stehen im Code (app/preferences.py).
|
|
-- value NULL: kein eigener Wert, es gilt die Erbung bzw. der Standard.
|
|
|
|
CREATE TABLE account_preferences (
|
|
account_id uuid NOT NULL REFERENCES auth_accounts (id) ON DELETE CASCADE,
|
|
key text NOT NULL,
|
|
value jsonb,
|
|
team_mode text NOT NULL DEFAULT 'free',
|
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (account_id, key),
|
|
CONSTRAINT account_preferences_key_len CHECK (char_length(key) BETWEEN 1 AND 60),
|
|
CONSTRAINT account_preferences_team_mode CHECK (team_mode IN ('free', 'locked'))
|
|
);
|