also making sure that the notification actor id is unique in the keep delete table

This commit is contained in:
zhitomirskiyi 2011-01-31 11:42:49 -08:00
parent 2d078a212a
commit a789be737a

View file

@ -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') "+