-- Revert t-paliad-264 / m/paliad#95.
-- Restores Replik and Duplik to parent_id = NULL with the pre-fix
-- "Frist vom Gericht bestimmt" placeholder note. The pre-fix rows
-- carried legal_source = NULL and is_court_set = false; both
-- placeholder durations (4 weeks) are left untouched (the .up
-- migration did not modify them).
--
-- audit_reason set_config required for the mig 079 trigger.

SELECT set_config(
    'paliad.audit_reason',
    'mig 124 revert: unwind de.inf.lg Replik/Duplik sequencing back to pre-#95 placeholder state',
    true);

UPDATE paliad.deadline_rules
SET parent_id      = NULL,
    is_court_set   = false,
    legal_source   = NULL,
    deadline_notes = 'Frist vom Gericht bestimmt',
    deadline_notes_en = NULL
WHERE submission_code = 'de.inf.lg.replik'
  AND is_active = true;

UPDATE paliad.deadline_rules
SET parent_id      = NULL,
    is_court_set   = false,
    legal_source   = NULL,
    deadline_notes = 'Frist vom Gericht bestimmt',
    deadline_notes_en = NULL
WHERE submission_code = 'de.inf.lg.duplik'
  AND is_active = true;
