Error during installation over existant database

Summary
Error during installation over existant database

Steps to reproduce
mattermost-omnibus/jammy 10.6.1-0 amd64

Observed behavior
I am a very happy user of mattermost which was installed since many years with tgz
Unfortunatly, my server crashes with a RAID issue.
Il restore the backuped databases including mattermost but the software mattermost was not backuped.
So, I install the package from my distribution Ubuntu 22.04 (mattermost-omnibus/jammy 10.6.1-0 amd64
), setup with my config.json but during the setup, I have the following error message

Apr 05 18:26:06 2D17911 systemd[1]: Starting Mattermost...
Apr 05 18:26:06 2D17911 mattermost[268182]: {"timestamp":"2025-04-05 18:26:06.519 +02:00","level":"info","msg":"Successfully connected to cache backend","caller":"platform/service.go:193","backend":"lru","result":"OK"}
Apr 05 18:26:06 2D17911 mattermost[268182]: {"timestamp":"2025-04-05 18:26:06.519 +02:00","level":"info","msg":"Server is initializing...","caller":"platform/service.go:196","go_version":"go1.22.6"}
Apr 05 18:26:06 2D17911 mattermost[268182]: {"timestamp":"2025-04-05 18:26:06.520 +02:00","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@127.0.0.1:5432/mattermost?connect_timeout=10&sslmode=disable"}
Apr 05 18:26:06 2D17911 mattermost[268182]: Error: failed to initialize platform: cannot create store: failed to apply database migrations: driver: postgres, message: failed to execute migration, command: executing_query, originalError: pq: type "outgoingoauthconnections_granttype" already exists, query:
Apr 05 18:26:06 2D17911 mattermost[268182]: CREATE TYPE outgoingoauthconnections_granttype AS ENUM ('client_credentials', 'password');
Apr 05 18:26:06 2D17911 mattermost[268182]: CREATE TABLE IF NOT EXISTS outgoingoauthconnections (
Apr 05 18:26:06 2D17911 mattermost[268182]:     id varchar(26) PRIMARY KEY,
Apr 05 18:26:06 2D17911 mattermost[268182]:     name varchar(64),
Apr 05 18:26:06 2D17911 mattermost[268182]:     creatorid VARCHAR(26),
Apr 05 18:26:06 2D17911 mattermost[268182]:     createat bigint,
Apr 05 18:26:06 2D17911 mattermost[268182]:     updateat bigint,
Apr 05 18:26:06 2D17911 mattermost[268182]:     clientid varchar(255),
Apr 05 18:26:06 2D17911 mattermost[268182]:     clientsecret varchar(255),
Apr 05 18:26:06 2D17911 mattermost[268182]:     credentialsusername varchar(255),
Apr 05 18:26:06 2D17911 mattermost[268182]:     credentialspassword varchar(255),
Apr 05 18:26:06 2D17911 mattermost[268182]:     oauthtokenurl text,
Apr 05 18:26:06 2D17911 mattermost[268182]:     granttype outgoingoauthconnections_granttype DEFAULT 'client_credentials',
Apr 05 18:26:06 2D17911 mattermost[268182]:     audiences VARCHAR(1024)
Apr 05 18:26:06 2D17911 mattermost[268182]: );
Apr 05 18:26:06 2D17911 mattermost[268182]: CREATE INDEX IF NOT EXISTS idx_outgoingoauthconnections_name ON outgoingoauthconnections (name);
Apr 05 18:26:06 2D17911 mattermost[268182]: {"timestamp":"2025-04-05 18:26:06.586 +02:00","level":"error","msg":"failed to initialize platform: cannot create store: failed to apply database migrations: driver: postgres, message: failed to execute migration, command: executing_query, originalError: pq: type \"outgoingoauthconnections_granttype\" already exists, query: \n\nCREATE TYPE outgoingoauthconnections_granttype AS ENUM ('client_credentials', 'password');\n\nCREATE TABLE IF NOT EXISTS outgoingoauthconnections (\n    id varchar(26) PRIMARY KEY,\n    name varchar(64),\n    creatorid VARCHAR(26),\n    createat bigint,\n    updateat bigint,\n    clientid varchar(255),\n    clientsecret varchar(255),\n    credentialsusername varchar(255),\n    credentialspassword varchar(255),\n    oauthtokenurl text,\n    granttype outgoingoauthconnections_granttype DEFAULT 'client_credentials',\n    audiences VARCHAR(1024)\n);\n\nCREATE INDEX IF NOT EXISTS idx_outgoingoauthconnections_name ON outgoingoauthconnections (name);\n\n","caller":"commands/server.go:75"}

How can I solve the issue ?
thanks for your tips,

What version of Mattermost did you have running from “many years” ago? You need to restore that version, or the first ESR available after it (see Version archive - Mattermost documentation), then upgrade ESR to ESR until you get to 10.5.2, and then go to 10.6.1 if you want leading edge.

Thanks for your answer
Unfortunately, I don’t know the version I was running.
Is the version stored in the database ?
Why the process of installation is confused about
CREATE INDEX IF NOT EXISTS idx_outgoingoauthconnections_name ON outgoingoauthconnections (name);
I don’t understand the error since there is a IF NOT EXISTS argument.
thanks

I doubt it. It’s possible there’s something that could be extracted from the database that might help. I can ask.

I would make sure I had a good backup of the database. Then try with 4.10.10 and see if it’ll run without errors.

It is ok with 9.2.6 and mattermost is running but unfortunately, Desktop application is not OK :
The mattermost server you are accessing is incompatible with this version of Mattermost Desktop App. To connect to this server, try the following

  • Downgrade your Mattermost desktop App to version 5.10 or earlier

I upgrade to 9.3.3 and it is ok for the server
I upgrade to 9.4.5 and it is not good, message from migration with

mattermost[354401]: Error: failed to initialize platform: cannot create store: failed to apply database migrations: driver: postgres, message: failed to execute migration, command: executing_query, originalError: pq: type "outgoingoauthconnections_granttype" already exists, query:
Apr 06 00:20:21 2D17911 mattermost[354401]: CREATE TYPE outgoingoauthconnections_granttype AS ENUM ('client_credentials', 'password');
Apr 06 00:20:21 2D17911 mattermost[354401]: CREATE TABLE IF NOT EXISTS outgoingoauthconnections (
Apr 06 00:20:21 2D17911 mattermost[354401]:     id varchar(26) PRIMARY KEY,

You are running a Postgres database, correct? What version?

You need to have an app version that matches with your server: Desktop releases - Mattermost documentation

A browser would always work.

And from 9.2.6 I’d go to 9.5.13 It could easily have improved migration tools over a non-ESR.

postgresql 14 on the server
mattermost 9.3.3 on the server
mattermost-desktop 5.11 on my desktop (Ubuntu 24.04) and another users with Mac and Windows clients

finally, I have destroyed the empty table outgoingoauthconnections and migrated to 10.5.2
thanks,