mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
migration to fix email_logs not attached to a user
This commit is contained in:
parent
12051f79a8
commit
de58e58272
1 changed files with 16 additions and 0 deletions
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
|
Loading…
Add table
Add a link
Reference in a new issue