mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Staged users did not have a UserEmail
record.
This commit is contained in:
parent
305b9b2da0
commit
6e74f726cf
1 changed files with 28 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
class FixPrimaryEmailsForStagedUsers < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
execute <<~SQL
|
||||||
|
INSERT INTO user_emails (
|
||||||
|
user_id,
|
||||||
|
email,
|
||||||
|
"primary",
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) SELECT
|
||||||
|
users.id,
|
||||||
|
email_tokens.email,
|
||||||
|
'TRUE',
|
||||||
|
users.created_at,
|
||||||
|
users.updated_at
|
||||||
|
FROM users
|
||||||
|
LEFT JOIN user_emails ON user_emails.user_id = users.id
|
||||||
|
LEFT JOIN email_tokens ON email_tokens.user_id = users.id
|
||||||
|
WHERE staged
|
||||||
|
AND NOT active
|
||||||
|
AND user_emails.id IS NULL
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue