From 03e8aa31f4e480312aeb12bd812a5ecb10681b22 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi <ilya@joindiaspora.com> Date: Mon, 31 Jan 2011 11:02:51 -0800 Subject: [PATCH] fixed notifications migration --- .../20110130072907_notification_multiple_people.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/migrate/20110130072907_notification_multiple_people.rb b/db/migrate/20110130072907_notification_multiple_people.rb index 11e42c434b..15902c3fb4 100644 --- a/db/migrate/20110130072907_notification_multiple_people.rb +++ b/db/migrate/20110130072907_notification_multiple_people.rb @@ -38,7 +38,8 @@ class NotificationMultiplePeople < ActiveRecord::Migration "WHERE n1.keep_id != n2.id " + "AND n1.target_type = n2.target_type AND n1.target_id = n2.target_id " + "AND n1.recipient_id = n2.recipient_id AND n1.action = n2.action " + - "AND (n1.action = 'comment_on_post' OR n1.action = 'also_commented'))" + "AND (n1.action = 'comment_on_post' OR n1.action = 'also_commented') "+ + "GROUP BY n2.actor_id , n2.target_type , n2.target_id , n2.recipient_id , n2.action)" #have the notifications actors reference the notifications that need to be kept execute "UPDATE notification_actors, keep_delete "+ @@ -48,7 +49,11 @@ class NotificationMultiplePeople < ActiveRecord::Migration #delete all the notifications that need to be deleted execute "DELETE notifications.* " + "FROM notifications, keep_delete " + - "WHERE notifications.id = keep_delete.delete_id " + "WHERE notifications.id != keep_delete.keep_id AND "+ + "notifications.target_type = keep_delete.target_type AND "+ + "notifications.target_id = keep_delete.target_id AND "+ + "notifications.recipient_id = keep_delete.recipient_id AND "+ + "notifications.action = keep_delete.action" remove_column :notifications, :actor_id -- GitLab