Well, I tried to recreate the database and it didn't work.
What worked for me was to manually configure the options below on gitlab.rb. I'm using both gitlab and mattermost databases on a different server, could that be the problem?
mattermost['gitlab_enable'] = true
mattermost['gitlab_id'] = "<secret>"
mattermost['gitlab_secret'] = "<secret>"
mattermost['gitlab_auth_endpoint'] = "<secret>"
mattermost['gitlab_token_endpoint'] = "<secret>"
mattermost['gitlab_user_api_endpoint'] = "<secret>"