Bulk Update Email of Users

Hi, I am on the latest version of discourse. I have changed the domain from subdomain1.domain1.com to subdomain1.domain2.com.

My user emails have also changed from @domain1.com to @domain2.com.

I found a post to create RAKE test to do this. But this post is from 2017.

I understand we need to look at UserEmail.email now for the emails. Could you please suggest how to modify this rake task to cater to the table changes in discourse latest version.

I managed to solve this by directly accessing the DB from the docker instance

cd /var/discourse
./launcher enter app
su discourse
psql discourse

In the postgres console, run the following query

UPDATE user_emails
SET email = REPLACE (email, '@olddomain.com', '@newdomain.com');

Once this is done, the users can do a forgot password with their new email address and create a new password.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.