Gitlab Mattermost SSO fails

I have created a dump from the MM database of a stand alone installation:

pg_dump -U mmuser mattermost > /var/lib/postgresql/data/mattermost_dump.sql

Then I recovered the backup on the gitlab omnibus installation with embedded MM. I also copied over the MM data directory to the new server. I removed everything that was in the directory in the new server before copying.

When I try to use Gitlab SSO to login to MM it fails. The error message is something like “An account with that username already exists with different authentication method. Please use gitlab to sign in” (It is in german. I tried to translate.)

When I login with email and password, everything works as expected, but I can not change the authentication method to gitlab in the user settings. If I try it, the same error is shown.

Question: Can I migrate my old instance of MM to Gitlab MM, and use Gitlab SSO on the new instance? What do I need to change, to make it work?

Thank you,