# Upgrade from 9.4.5 to 9.5.x or 9. 7.3

**URL:** <https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580>\
**Category:** Uncategorized\
**Created:** [May 8, 2024, 6:25pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580 "2024-05-08T18:25:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zugang](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zugang](https://forum.mattermost.com/u/zugang)\
**Post date:** [May 8, 2024, 6:25pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/1 "2024-05-08T18:25:16Z")

</div>

Hi,  
I tried to Update mattermost with Docker. But I got this message:

First I tried 9.4.5 to 9.5.0.  
But I got this message:

> idx\_poststats\_userid ON poststats(userid)  
> mattermost | Error: failed to initialize platform: cannot cre ate store: failed to apply database migrations: driver: postgres, message: faile d to execute migration, command: executing\_query, originalError: pq: relation “p oststats” does not exist, query:  
> mattermost |  
> mattermost | – morph:nontransactional  
> mattermost | CREATE INDEX CONCURRENTLY IF NOT EXISTS idx\_post stats\_userid ON poststats(userid)  
> mattermost |  
> mattermost | Usage:  
> mattermost | mattermost [flags]  
> mattermost | mattermost [command]  
> mattermost |  
> mattermost | Available Commands:  
> mattermost | completion Generate the autocompletion script for the specified shell  
> mattermost | db Commands related to the database  
> mattermost | export Export data from Mattermost  
> mattermost | help Help about any command  
> mattermost | import Import data.  
> mattermost | jobserver Start the Mattermost job server  
> mattermost | server Run the Mattermost server  
> mattermost | version Display version information  
> mattermost |  
> mattermost | Flags:  
> mattermost | -c, --config string Configuration file to us e.  
> mattermost | -h, --help help for mattermost  
> mattermost |  
> mattermost | Use “mattermost [command] --help” for more infor mation about a command.  
> mattermost |  
> mattermost exited with code 1

How can I upgrade or fix this upgrade?

---

<div class="post-metadata">

**Author:** ![zugang](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zugang](https://forum.mattermost.com/u/zugang)\
**Post date:** [May 14, 2024, 4:35pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/2 "2024-05-14T16:35:49Z")

</div>

does anybody have an idea?

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [May 16, 2024, 6:07am UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/3 "2024-05-16T06:07:52Z")

</div>

It looks like your previous migrations didn’t work.

Could you run this: `select * from db_migrations order by version desc limit 10;` and post the output?

Also, please use the latest dot release of 9.5 instead of 9.5.0.

---

<div class="post-metadata">

**Author:** ![zugang](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zugang](https://forum.mattermost.com/u/zugang)\
**Post date:** [May 16, 2024, 5:06pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/4 "2024-05-16T17:06:47Z")

</div>

> [@agnivade](#):
>
> `select * from db_migrations order by version desc limit 10;`

Hi,

first: Thanks a lot for your support!!!  
Here is the output:

select \* from db\_migrations order by version desc limit 10;  
version | name  
---------±-------------------------------------------------  
117 | msteams\_shared\_channels  
116 | create\_outgoing\_oauth\_connections  
115 | user\_reporting\_changes  
114 | sharedchannelremotes\_drop\_nextsyncat\_description  
113 | create\_retentionidsfordeletion\_table  
112 | rework\_desktop\_tokens  
111 | update\_vacuuming  
109 | create\_persistent\_notifications  
108 | remove\_orphaned\_oauth\_preferences  
107 | threadmemberships\_cleanup  
(10 rows)

---

<div class="post-metadata">

**Author:** ![zugang](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zugang](https://forum.mattermost.com/u/zugang)\
**Post date:** [May 16, 2024, 5:25pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/5 "2024-05-16T17:25:56Z")

</div>

When I upgrad to 9.5.5 I have the same problem

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [May 17, 2024, 5:32am UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/6 "2024-05-17T05:32:48Z")

</div>

Ok, that’s a bit strange. Because it shows the migration 115 as complete but that didn’t happen.

Anyways, you can run this:

```auto
CREATE MATERIALIZED VIEW IF NOT EXISTS poststats AS
SELECT userid, to_timestamp(createat/1000)::date as day, COUNT(*) as numposts, MAX(CreateAt) as lastpostdate
FROM posts 
GROUP BY userid, day;

```

on the DB, and then re-attempt the upgrade to 9.5.5.

---

<div class="post-metadata">

**Author:** ![zugang](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zugang](https://forum.mattermost.com/u/zugang)\
**Post date:** [May 17, 2024, 3:51pm UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/7 "2024-05-17T15:51:45Z")

</div>

> [@agnivade](#):
>
> ```auto
> CREATE MATERIALIZED VIEW IF NOT EXISTS poststats AS
> SELECT userid, to_timestamp(createat/1000)::date as day, COUNT(*) as numposts, MAX(CreateAt) as lastpostdate
> FROM posts 
> GROUP BY userid, day;
> 
> ```

This helped! Thank you so much!!!

What is currently recommended? Should I upgrade to 9.7 or still 9.5? What do you think?

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [May 28, 2024, 8:37am UTC](https://forum.mattermost.com/t/upgrade-from-9-4-5-to-9-5-x-or-9-7-3/18580/8 "2024-05-28T08:37:54Z")

</div>

You can upgrade to 9.7.
