# Migrate from mattermost API and DB help

**URL:** <https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469>\
**Category:** Community Support\
**Created:** [January 15, 2025, 3:59pm UTC](https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469 "2025-01-15T15:59:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetash89](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vetash89](https://forums.rocket.chat/u/vetash89)\
**Post date:** [January 15, 2025, 3:59pm UTC](https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469/1 "2025-01-15T15:59:32Z")

</div>

Hello everyone! I’m trying to migrate from Mattermost to RocketChat. Both are self-hosted in Docker containers.

I’m extracting Mattermost data directly from a PostgreSQL database and sending it to RocketChat via the API.  
I’ve successfully migrated users, channels, and private channels, but I’m stuck on messages.

When I transfer messages via the API, there’s no way to set the timestamp. As a result, the messages appear in the chat as if they were sent just now, whereas I need them to display with the correct date.

If I try inserting data directly into MongoDB, the messages don’t appear in the chat.

So I have two questions:

1 Is it possible to send a message in such a way that it appears with a past date?

2 How can I make Rocket.Chat display messages that were inserted directly into MongoDB?

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [January 16, 2025, 7:29pm UTC](https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469/2 "2025-01-16T19:29:43Z")

</div>

Hi.

Can you tell a bit about your Rocket setup please?

Like this:

> <https://gist.github.com/reetp/a66149d5f060f260643a353ca7067a98#information-that-support-or-devs-will-require>

Any specific reasons why you are moving? Just curious as to what your needs are!

Yes messages will be tricky. I think it needs a direct injection to the DB.

I’ll try & see if anyone backstage has experience.

---

<div class="post-metadata">

**Author:** ![vetash89](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vetash89](https://forums.rocket.chat/u/vetash89)\
**Post date:** [January 18, 2025, 7:16pm UTC](https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469/3 "2025-01-18T19:16:49Z")

</div>

Why i want to migrate:

MM Mobile app getting worse for several years, slow UI, messaging, etc. My team mostly mobile app users, so we want to move to something different.

Seems like I figured it out.

> [@vetash89](#):
>
> 1 Is it possible to send a message in such a way that it appears with a past date?

No, api does not have such fields.

> [@vetash89](#):
>
> 2 How can I make Rocket.Chat display messages that were inserted directly into MongoDB?

Before put data into mongo database message object must include `_id` field. After reading code i notice that id is random generated `string` not object, if message missing this - mongo generate \_id as an object. So i just implement code like RC uses in internal libs in my importer and it works.

Thanks!

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [January 18, 2025, 11:30pm UTC](https://forums.rocket.chat/t/migrate-from-mattermost-api-and-db-help/21469/4 "2025-01-18T23:30:43Z")

</div>

> [@vetash89](#):
>
> MM Mobile app getting worse for several years, slow UI, messaging, etc. My team mostly mobile app users, so we want to move to something different.

Cool. Nice to know and welcome!

> [@vetash89](#):
>
> No, api does not have such fields.

Yes I did say that…

> [@reetp](#):
>
> Yes messages will be tricky. I think it needs a direct injection to the DB.

And…

> [@vetash89](#):
>
> So i just implement code like RC uses in internal libs in my importer and it works.

Excellent.

Be good if you can post some code for others (open source is about sharing!)
