I updated the rake task so that it logs a “merge user” action instead of “delete user” in the staff logs.
I’m little bit confused. I don’t have
users:merge task in my docker container. Does it already in
v2.1.0.beta2 +16 version?
Yes, it’s part of Discourse since 2.0.0.beta4
Hm. Here what I have when I run
And I rebuild discourse container in a last week.
Oh, I see. The task doesn’t show up in that list because it doesn’t have a description. I’m going to add one.
But you should be able to execute the task as shown in the first post:
Here is what I have:
root@host:/var/www/discourse# rake users:merge['source','target'] rake aborted! PG::UndefinedFunction: ОШИБКА: функция jsonb_build_object(unknown, text, unknown, text, unknown, text, unknown, text) не существует LINE 4: jsonb_build_object( ^ HINT: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов. /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/pg.rb:92:in `async_exec' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/pg.rb:92:in `async_exec' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mini_sql-0.1.9/lib/mini_sql/connection.rb:104:in `run' /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mini_sql-0.1.9/lib/mini_sql/connection.rb:76:in `exec' /var/www/discourse/app/jobs/regular/update_username.rb:63:in `update_notifications' /var/www/discourse/app/jobs/regular/update_username.rb:22:in `execute' /var/www/discourse/app/services/username_changer.rb:46:in `update_username' /var/www/discourse/app/services/user_merger.rb:30:in `update_username' /var/www/discourse/app/services/user_merger.rb:10:in `merge!' /var/www/discourse/lib/tasks/users.rake:47:in `block in <top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' Tasks: TOP => users:merge (See full trace by running task with --trace)
ERROR: function jsonb_build_object(unknown, text, unknown, text, unknown, text, unknown, text) doesn't exist
You need to upgrade PostgreSQL to version 9.5 or greater. The current docker container uses Postgres 10 by default.
Ou, I see now. Thank you very much!
The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience.
Disabling the plugin solves the problem, but I like the plugin, so ideas on how I could fix it are very welcome!
The line in question is at https://github.com/discourse/discourse-voting/blob/master/plugin.rb#L112 and I think I’ve fixed it at https://github.com/discourse/discourse-voting/pull/33.
Maybe. Plugins can subscribe to the
:merging_users event. It’s possible that the Voting plugin needs to do that.
Just found out about this and immediately tried it out. Works like a charm. Thank you for this nice feature!
Is there any way to empty the second emails field? I merged two users and then later realized I should not have done so. Now I can’t create the user again because the email address is in the second emails field.
Obviously some sort of UI fix would be lovely long term for emptying/changing these addresses, but I know that’s likely a ways off. In the meantime I’d be grateful for command line steps. Thanks in advance!
Sure, this can be done in the rails console within the container.
rails c # restrict to secondary emails, just in case you try to delete the wrong email UserEmail.where(email: "email@example.com", primary: false).destroy_all # probably not needed, but better safe than sorry EmailToken.where(email: "firstname.lastname@example.org").destroy_all
This is helpful. This seems like something that people will need with some frequency; it’d probably be good if this were a rake task.
These commands have become an important and handy part of my workflow to bring back defunct users who have become unreachable, or to invite people who attend or apply for our events to join our community. Often there is a need to change the email address of the existing account, while retaining the correspondence with a new, staged user.
I do share @pfaffman’s challenge.
The answer for now seems to be to merge the user, delete the secondary email address of the remaining user using @gerhard’s rails commands, then change the email address via the web interface. (in my case it’s via wordpress SSO). Presto, done. But it’s three commands involving some copy pasting and is a bit time consuming.
Some suggestions follow. Curious to hear reactions.
How about a users:swapemail command to run before the merge?
rake users:swapemail[user1,user2] rake users:merge[user1,user2]
Add ability to edit secondary email addresses via the admin UI?
I have SSO on my site so can’t use this, but for those who don’t it would be useful to be able to edit the primary and secondary email addresses directly via the user admin.
Add ability to update secondary email via SSO?
This might already be possible via API, but support for a secondary email field would need to be added to the SSO provider, in my case wordpress.
Move primary email to secondary when primary email is changed?
Perhaps a simpler, more sustainable long-term solution that doesn’t require alot of other changes would be to simply change it so when a user or admin (via web or SSO) changes the primary email, it moves the old email to the secondary email field first. This could be enabled with an admin site setting.
Tickets Plugin :tickets:
Is there any risk to merging someone’s shadow/anonymous account into their account? I just did it and it seemed to work fine.