-- Revert mig 104 — restore the bracket-bearing Einspruch names and
-- flip the CCR priority back to 'informational'.

SELECT set_config(
    'paliad.audit_reason',
    'mig 104 down: restore "Einspruch (R. 19 VerfO)" and "Einspruch (R. 19 i.V.m. R. 46 VerfO)" names + flip upc.inf.cfi.ccr priority back to informational',
    true);

UPDATE paliad.deadline_rules dr
   SET name_en = 'Preliminary Objection (RoP 19 in conjunction with RoP 46)'
  FROM paliad.proceeding_types pt
 WHERE dr.proceeding_type_id = pt.id
   AND pt.code = 'upc.rev.cfi'
   AND dr.submission_code = 'upc.rev.cfi.prelim'
   AND dr.lifecycle_state = 'published'
   AND dr.name_en = 'Preliminary Objection';

UPDATE paliad.deadline_rules dr
   SET name = 'Einspruch (R. 19 i.V.m. R. 46 VerfO)'
  FROM paliad.proceeding_types pt
 WHERE dr.proceeding_type_id = pt.id
   AND pt.code = 'upc.rev.cfi'
   AND dr.submission_code = 'upc.rev.cfi.prelim'
   AND dr.lifecycle_state = 'published'
   AND dr.name = 'Einspruch';

UPDATE paliad.deadline_rules dr
   SET name_en = 'Preliminary Objection (RoP 19)'
  FROM paliad.proceeding_types pt
 WHERE dr.proceeding_type_id = pt.id
   AND pt.code = 'upc.inf.cfi'
   AND dr.submission_code = 'upc.inf.cfi.prelim'
   AND dr.lifecycle_state = 'published'
   AND dr.name_en = 'Preliminary Objection';

UPDATE paliad.deadline_rules dr
   SET name = 'Einspruch (R. 19 VerfO)'
  FROM paliad.proceeding_types pt
 WHERE dr.proceeding_type_id = pt.id
   AND pt.code = 'upc.inf.cfi'
   AND dr.submission_code = 'upc.inf.cfi.prelim'
   AND dr.lifecycle_state = 'published'
   AND dr.name = 'Einspruch';

UPDATE paliad.deadline_rules dr
   SET priority = 'informational'
  FROM paliad.proceeding_types pt
 WHERE dr.proceeding_type_id = pt.id
   AND pt.code = 'upc.inf.cfi'
   AND dr.submission_code = 'upc.inf.cfi.ccr'
   AND dr.lifecycle_state = 'published'
   AND dr.priority = 'optional';
