After some month of experience using Mattermost - which we actually like - we would like to reorganize and simplify the channels we use. Unfortunately I didn’t find a way to merge channels or move messages to another channel (I found that feature request https://mattermost.uservoice.com/forums/306457-general/suggestions/11080068-move-a-message-to-another-channel). So currently there seems to be no built-in way of doing this, unfortunately.
Is there a hacky way of moving messages or merging channels?
Thanks for any hints!
There’s no easy way to do this right now but it should be possible with some database manipulation. We recommend against modifying the database directly since it can have unintentional side effects that break your system. That said, I can point you in the right direction and I strongly recommend backing up your database before making any manual changes to it.
So I haven’t tried this myself, but in theory you should be able to:
SELECT Id FROM Channels WHERE Name = 'channel-to-keep'; - save this Id and I’ll refer to it as finalId
SELECT Id FROM Channels WHERE Name = 'channel-to-be-merged'; - save this Id and I’ll refer to it as oldId
UPDATE Posts SET ChannelId = 'finalId' WHERE ChannelId = 'oldId'; - this will move all the posts over
DELETE FROM ChannelMembers WHERE ChannelId = 'oldId'; - this will remove any old channel member objects for the old channel and users from the old channel will need to manually join the final channel if they weren’t already in it
DELETE FROM Channels WHERE ChannelId = 'oldId'; - this will remove the old channel
You will also need to update or delete the old channel Id in additional tables if you have IncomingWebhooks, OutgoingWebhooks, or Commands on that channel.
Note those queries are given in MySQL syntax and might be slightly different for PostgreSQL.
Thanks! Will try it out in calm moment. I’ll let you know about the outcome.
Considering this is quite an old post, I was wondering if there is now an administrative tool to do this or if this is still the best way.
tarek : )
Thank you for your question,
At the moment, there isn’t a way to merge channels or move messages. The method
jwilander laid out above is still the best way.
Manually changing the channel ID on posts in the database like this procedure is still the only way I could find to move messages between channels, but for the record it does work in Mattermost 5.1.
I did have some trouble getting some sort of caching out of the way, even after a restart and cold-flushing client browsers it still quite stubbornly held on to serving cached material. I found manually updating one of the edited time stamp of a post before the earliest moved message (in both rooms) to a current time triggered some kind of a reload and the channel display updated.
Now it is 2019. Any progress since 2016? How long does it take to paste 5 SQL statements into Go code?
Thank you for your post @jwilander, as old as it is, it stills works in 5.11.0., and it served me well.
I would also like to point that the last point (number 5) command should be
DELETE FROM Channels WHERE Id = 'oldId'; because
Id is the right column in the table