From d6344d337000fa0458835a4ea9c7948cc91d7b19 Mon Sep 17 00:00:00 2001 From: poveyd <32199157+poveyd@users.noreply.github.com> Date: Tue, 28 Apr 2020 11:43:52 +0100 Subject: [PATCH] Update cycle_notification_history.sql --- database_maintenance/cycle_notification_history.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/database_maintenance/cycle_notification_history.sql b/database_maintenance/cycle_notification_history.sql index c113e3b1f..cc7698a09 100644 --- a/database_maintenance/cycle_notification_history.sql +++ b/database_maintenance/cycle_notification_history.sql @@ -5,7 +5,7 @@ ALTER TABLE notification_history_pivot ADD PRIMARY KEY (id); -- CREATE TRIGGER update_pivot BEFORE UPDATE ON notification_history create trigger to update notification_history_pivot when update to notification_history -create foreign key constraints in notification_history_pivot +Create foreign key constraints in notification_history_pivot with dummy names - prefix with "nh_" insert data into notification_history_pivot in batches @@ -14,8 +14,10 @@ create remaining indices on notification_history_pivot -- Run basic sanity checks on data in notification_history_pivot, ensuring same number of entries present in notification_history and notification_history_pivot ALTER TABLE notification_history RENAME TO notification_history_old; --- TODO: Drop constraints on notification_history_old +Drop constraints on notification_history_old ALTER TABLE notification_history_pivot RENAME TO notification_history; +Create foreign key constraints in notification_history using correct names. Names of constraints will now be available after step above ("Drop constraints on notification_history_old"). +Drop constraints in notification_history that are prefixed with "nh_". -- Run sanity checks on data in notification_history_pivot -- 1. Ensure same number of entries in notification_history and notification_history_pivot