-- t-paliad-111 B6: store the legal rule citation (RoP.023, R.151, …) on
-- the Deadline row directly so the /deadlines list and project-detail
-- /deadlines tab can render REGEL without having to JOIN paliad.deadline_rules.
--
-- Before: the Fristenrechner save flow concatenated the rule code into
-- the title ("RoP.023 — Klageerwiderung") because deadlines had nowhere
-- else to put it; the REGEL column ended up showing "—" because rule_id
-- on the bulk-save payload is always NULL (no rule UUID round-trips
-- through the public Fristenrechner API).
--
-- After: the save flow sends rule_code as a plain string field, the
-- title stays clean ("Klageerwiderung"), and the list join becomes
-- redundant — the deadline owns its citation.

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

COMMENT ON COLUMN paliad.deadlines.rule_code IS
    'Legal rule citation (e.g. "RoP.023") as it should appear in REGEL. '
    'Free text — not FK-constrained — so the value survives rule-table '
    'rewrites and accepts citations from sources outside paliad.deadline_rules.';
