From a789be737a44117f4dd9240af81c3b16f3adcf10 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Mon, 31 Jan 2011 11:42:49 -0800 Subject: [PATCH] also making sure that the notification actor id is unique in the keep delete table --- db/migrate/20110130072907_notification_multiple_people.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20110130072907_notification_multiple_people.rb b/db/migrate/20110130072907_notification_multiple_people.rb index 9e1786f16..f0322a96d 100644 --- a/db/migrate/20110130072907_notification_multiple_people.rb +++ b/db/migrate/20110130072907_notification_multiple_people.rb @@ -25,7 +25,7 @@ class NotificationMultiplePeople < ActiveRecord::Migration #select all the notifications to keep execute "CREATE TEMPORARY TABLE keep_table " + - "(SELECT id as keep_id, target_type , target_id , recipient_id , action " + + "(SELECT id as keep_id, actor_id , target_type , target_id , recipient_id , action " + "FROM notifications WHERE action = 'comment_on_post' OR action = 'also_commented' " + "GROUP BY target_type , target_id , recipient_id , action) " @@ -36,6 +36,7 @@ class NotificationMultiplePeople < ActiveRecord::Migration "n2.actor_id, n1.target_type, n1.target_id, n1.recipient_id, n1.action " + "FROM keep_table n1, notifications n2 " + "WHERE n1.keep_id != n2.id " + + "AND n1.actor_id != n2.actor_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') "+