Adds paliad.users.forum_pref so /tools/fristenrechner can pre-narrow the proceeding picker to the user's typical inbox channel without re-asking on every visit. The new column threads through the User model, the userColumns SELECT, and UpdateProfileInput so the existing PATCH /api/me handler accepts it without a new endpoint. Allowed values mirror the channel chips m named in t-paliad-157: - cms → UPC - bea → national-DE - posteingang → national-DE (slower channel, same forums) NULL means "no preference, picker shows everything"; URL ?inbox= overrides per-visit (frontend lands in the next commit). The CHECK constraint enforces the 3-value enum at the DB layer; isValidForumPref mirrors it in the service so callers see a typed error instead of a raw pq violation. Empty string in the PATCH body clears the preference, consistent with the EscalationContactID convention. Migration 064 applied to the live Supabase pool; tracker bumped to v64 so the boot-time runner skips re-applying. Refs m/paliad#15.
33 lines
1.4 KiB
SQL
33 lines
1.4 KiB
SQL
-- 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.';
|