mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
migration to fix email_logs not attached to a user
This commit is contained in:
16
db/migrate/20160201181320_fix_email_logs.rb
Normal file
16
db/migrate/20160201181320_fix_email_logs.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class FixEmailLogs < ActiveRecord::Migration
|
||||
def up
|
||||
execute <<-SQL
|
||||
UPDATE email_logs
|
||||
SET user_id = u.id
|
||||
FROM email_logs el
|
||||
LEFT JOIN users u ON u.email = el.to_address
|
||||
WHERE email_logs.id = el.id
|
||||
AND email_logs.user_id IS NULL
|
||||
AND NOT email_logs.skipped
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user