-- Each user's loudness-normalization preference (M464 #4998). It is kept on -- the server, not per device, so the web player, the Android app and the -- leveled stream for UPnP/Sonos all apply the same one. -- -- mode: off, auto (album gain while an album plays in order, otherwise -- track gain), track or album. -- target: the loudness tracks are leveled to, in LUFS. -- boost: headroom raises quiet tracks only as far as their true peak -- allows; limiter raises them all the way and limits the peaks. -- -- No row means the defaults, which are the column defaults here and -- library.DefaultNormalizationPrefs in Go (a test holds them equal). CREATE TABLE user_normalization_prefs ( user_id uuid PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE, mode text NOT NULL DEFAULT 'auto' CHECK (mode IN ('off', 'auto', 'track', 'album')), target_lufs smallint NOT NULL DEFAULT -18 CHECK (target_lufs IN (-18, -16, -14)), boost text NOT NULL DEFAULT 'headroom' CHECK (boost IN ('headroom', 'limiter')), updated_at timestamptz NOT NULL DEFAULT now() );