Database schema cannot be upgraded. You must not skip a version


#1

Summary

When attempting to start Mattermost with Gitlab, I get a 502 Bad Gateway error.

$ tail -f var/log/gitlab/mattermost/current outputs:

2017-02-12_02:26:12.82313 [2017/02/11 22:26:12 AST] [CRIT] The database schema version of 2.2.0 cannot be upgraded.  You must not skip a version.
2017-02-12_02:26:14.01786 [2017/02/11 22:26:14 AST] [INFO] Loaded system translations for 'en' from '/opt/gitlab/embedded/service/mattermost/i18n/en.json'
2017-02-12_02:26:14.01787 [2017/02/11 22:26:14 AST] [INFO] Current version is 3.5.0 (3.5.0/Tue Nov 15 18:55:53 UTC 2016/3f19ccf1b1a6efdcc990cf8a0270ec4ffc0c6e22/none)
2017-02-12_02:26:14.01787 [2017/02/11 22:26:14 AST] [INFO] Enterprise Enabled: false
2017-02-12_02:26:14.01788 [2017/02/11 22:26:14 AST] [INFO] Current working directory is /opt/gitlab/embedded/service/mattermost
2017-02-12_02:26:14.01788 [2017/02/11 22:26:14 AST] [INFO] Loaded config file from /var/opt/gitlab/mattermost/config.json
2017-02-12_02:26:14.01789 [2017/02/11 22:26:14 AST] [INFO] Server is initializing...
2017-02-12_02:26:14.01789 [2017/02/11 22:26:14 AST] [INFO] Pinging SQL master database
2017-02-12_02:26:14.02038 [2017/02/11 22:26:14 AST] [INFO] Pinging SQL replica-0 database
2017-02-12_02:26:14.02712 [2017/02/11 22:26:14 AST] [CRIT] The database schema version of 2.2.0 cannot be upgraded.  You must not skip a version.

Steps to reproduce

Configure /etc/gitlab/gitlab.rb with the following settings:

mattermost_external_url 'https://mattermost.my-site.com'
mattermost_nginx['redirect_http_to_https'] = true
mattermost_nginx['ssl_certificate'] = "/etc/gitlab/ssl/git.my-site.com.crt"
mattermost_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/git.my-site.com.key"
mattermost['service_use_ssl'] = true

Reconfigure gitlab with:

$ sudo gitlab-ctl reconfigure

After much searching, I’ve found what seemed to be the answer here:

Here’s the relevant script:

# /bin/bash

declare -a versions=("1.0.0" "1.1.0" "1.2.1" "1.3.0" "1.4.0" "2.0.0" "2.1.0" "2.2.0"...up to "3.5.0")

for v in "${versions[@]}"
do
     wget https://releases.mattermost.com/${v}/mattermost-team-${v}-linux-amd64.tar.gz -O - | tar -xz
     gitlab-ctl stop mattermost
     rm /opt/gitlab/embedded/bin/mattermost
     cp mattermost/bin/platform /opt/gitlab/embedded/bin/mattermost
     rm /var/opt/gitlab/mattermost/config.json
     cp mattermost/config/config.json /var/opt/gitlab/mattermost/config.json
     gitlab-ctl reconfigure
     gitlab-ctl start mattermost
done

However, this doesn’t work for me, as I still get the skipped version error above. I’ve also tried what’s suggested here:
https://docs.gitlab.com/omnibus/gitlab-mattermost/

sudo -u mattermost -i bash
cd /opt/gitlab/embedded/service/mattermost
/opt/gitlab/embedded/bin/mattermost -config='/var/opt/gitlab/mattermost/config.json' -upgrade_db_30

Then I get an error:

Error: unknown shorthand flag: 'u' in -upgrade_db_30

I also want to mention that I do not care about any Mattermost history. It’s completely fine if all previous Mattermost data is lost, as I had only briefly tested Mattermost over a year ago. Any help would be greatly appreciated, thanks.


#2

@mnordine really sorry for the long delay in responding,

Here are a couple of links that might help with similar issues

Let us know if the above helps resolve the issues or not,


#3

Thanks for replying @jasonblais, but I’ve still not succeeded and I’ve checked out the links you’ve provided. Is there a way I can just completely remove the existing database and start fresh?


#4

Hi @mnordine,

You might find some help in the Command Line Tools documentation.