Mattermost, Inc.

[HOWTO] Amalgamate accounts post 3.0 upgrade

I was very irritated to see that upgrading to 3.0 resulted in posts being divided into the old and new users.

My unifying user was subscribed again to all forums. Once this happened, I moved the posts from the old user to the new. After that, a ctrl-shift-r to properly reload, and all posts belong to the main user.

Here are the SQL commands.

UPDATE `Posts` SET `UserId`='ID_YOU_WANT' WHERE `UserId`='OLD_ID'
UPDATE `ChannelMembers` SET `UserId`='ID_YOU_WANT' WHERE `UserId`='OLD_ID'
UPDATE `TeamMembers` SET `UserId`='ID_YOU_WANT' WHERE `UserId`='OLD_ID'

To move all direct messages, first find messages from your old accounts by searching for the message contentin the Posts table. Create a new channel and find the ID of the new channel as well.

To move the posts, do the following:

UPDATE `Posts` SET `ChannelId` = 'NEW_DIRECTMESSAGE_CHANNEL' WHERE `ChannelId` = 'OLD_DIRECTMESSAGE_CHANNEL'

When you are sure everything is right, delete the old channels and the member entries like so:

DELETE FROM `Channels` WHERE `Id` = 'OLD_DIRECTMESSAGE_CHANNEL'
DELETE FROM `ChannelMembers` WHERE `ChannelId` = 'OLD_DIRECTMESSAGE_CHANNEL'

At this point, you may be tempted to delete the old users. If you do, just make sure you delete the preferences as well, or MM will fail and give you a 503

  • This doesn’t appear to have any negative consequences on attachments and the few other things I checked.

  • Do not delete any files in the data directory.

  • You may have to delete duplicates in channelmembers if you’ve already joined those channels.

After backing up and confirming this, I deleted the old users.

I hope that helps others a bit.

1 Like