-- 156_trigger_event_id_partial_deprecation.down — t-paliad-331 / m/paliad#149

BEGIN;

SELECT set_config(
    'paliad.audit_reason',
    'mig 156 down: restore trigger_event_id on the 2 hybrid rules',
    true
);

-- Restore the trigger_event_id values from the same-TX snapshot.
UPDATE paliad.sequencing_rules sr
   SET trigger_event_id = pre.trigger_event_id
  FROM paliad.sequencing_rules_pre_156 pre
 WHERE sr.id = pre.id
   AND sr.trigger_event_id IS NULL
   AND pre.trigger_event_id IS NOT NULL;

DROP TABLE IF EXISTS paliad.sequencing_rules_pre_156;

COMMIT;
