mend
This commit is contained in:
parent
36d7973005
commit
66fea22f60
1 changed files with 26 additions and 0 deletions
26
db/migrate/20110211021925_fix_target_on_notification.rb
Normal file
26
db/migrate/20110211021925_fix_target_on_notification.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class FixTargetOnNotification < ActiveRecord::Migration
|
||||
def self.up
|
||||
execute("UPDATE notifications " +
|
||||
"SET target_type='Post' " +
|
||||
"WHERE action = 'comment_on_post' OR action = 'also_commented'")
|
||||
|
||||
execute("UPDATE notifications " +
|
||||
"SET target_type='Request' " +
|
||||
"WHERE action = 'new_request' OR action = 'request_accepted'")
|
||||
|
||||
execute("UPDATE notifications " +
|
||||
"SET target_type='Mention' " +
|
||||
"WHERE action = 'mentioned'")
|
||||
|
||||
execute("create temporary table t1 "+
|
||||
"(select notifications.id as n_id " +
|
||||
"from notifications LEFT JOIN mentions "+
|
||||
"ON notifications.target_id = mentions.id "+
|
||||
"WHERE notifications.action = 'mentioned' AND mentions.id IS NULL)")
|
||||
|
||||
execute("DELETE notifications.* FROM notifications, t1 WHERE notifications.id = t1.n_id")
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue