-- t-paliad-258 / m/paliad#89 — binary Auto/Custom Rule model on the
-- deadline form.
--
-- t-paliad-251 shipped the form with a full deadline_rules catalog
-- dropdown. m's verdict: too noisy (4 "Oral hearings" across UPC CFI,
-- UPC CoA, DPMA, EPO etc.). Replace with a binary model:
--
--   1. Auto    — rule_id derived from the chosen event_type, displayed
--                read-only.
--   2. Custom  — rule_id is NULL and the lawyer's free-text label is
--                stored here.
--
-- The column is additive + nullable: existing rows keep their
-- deadline_rule_id and read as Auto-equivalent. A future row with both
-- columns NULL renders as "keine Regel" (matches today's no-rule state).

ALTER TABLE paliad.deadlines
    ADD COLUMN IF NOT EXISTS custom_rule_text text;

COMMENT ON COLUMN paliad.deadlines.custom_rule_text IS
    'Free-text rule label entered when the lawyer chose Custom on the '
    'deadline form (t-paliad-258). Mutually exclusive with rule_id at '
    'the application layer: Auto path sets rule_id and leaves this '
    'NULL; Custom path sets this and leaves rule_id NULL. Display '
    'surfaces prefer the rule_id-joined deadline_rules.name when '
    'present, else fall back to custom_rule_text + a "Custom" badge.';
