-- t-paliad-157 / m/paliad#15: persisted Fristenrechner inbox-channel
-- preference.
--
-- Stores the user's typical inbox channel (cms = UPC, bea = national-DE,
-- posteingang = national-DE — slower channel, same set of forums) so
-- /tools/fristenrechner can pre-narrow the proceeding picker without
-- re-asking on every visit. The chip on the page persists changes here
-- via the existing PATCH /api/me endpoint. URL ?inbox= overrides for
-- the current visit so a colleague can share a CMS-narrowed link
-- without flipping anyone's saved preference.
--
-- The 3-value CHECK keeps the schema honest while leaving room to add
-- epa / dpma channels later (the Fristenrechner already supports those
-- forums via the fine-grained B2 chips; the inbox-channel chip starts
-- with the channels m named explicitly in t-paliad-157).
--
-- NULL = no preference, picker shows everything. Default for existing
-- rows.

ALTER TABLE paliad.users
    ADD COLUMN forum_pref text;

ALTER TABLE paliad.users
    ADD CONSTRAINT users_forum_pref_check
    CHECK (forum_pref IS NULL OR forum_pref IN ('cms', 'bea', 'posteingang'));

COMMENT ON COLUMN paliad.users.forum_pref IS
    'Persisted Fristenrechner inbox-channel preference (#15). '
    'cms = UPC; bea = national-DE; posteingang = national-DE (slower '
    'channel, same forums). NULL = no preference (picker shows '
    'everything). URL ?inbox= overrides for the current visit. Set via '
    'PATCH /api/me.';
