Rake task for merging users

So, if you’re using SSO on your site is it not possible to complete the rake merge task? The fine folks over at Communiteq (formerly DiscourseHosting) say they get this error message:

ActiveRecord::RecordNotSaved: Failed to save the new associated primary_email
/var/www/discourse/app/services/user_merger.rb:359:in `delete_source_user'

This also causes issues when trying to use the plugin from @Dannii because it looks like his process is trying to do this step first.

Any suggested workarounds for merging users for SSO sites? What we have happen is that a person changes from one organization to another and so they get a new account through the SSO process (they have a new email), but since it is the same person, we’d like to be able to merge the accounts once they’ve established themselves at their new location.