Pierre's solution is fine for new installs, but if you already have data in the DB, you need to migrate instead. The cleanest, most fail-safe way is to create a backup, which contains the DB too:
gitlab-rake gitlab:backup:create
The backup file will be located at /var/opt/gitlab/backups.
Alternatively, you can try:
sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dumpall --username=gitlab-psql --host=/var/opt/gitlab/postgresql
Then you can import the DB into the existing Postgres instance with:
psql -f /tmp/database.sql
Then you need to reconfigure and restart too:
gitlab-ctl start && gitlab-ctl reconfigure && gitlab-ctl restart
It starts with start because you need to make sure GitLab is running. That's because, however weird that sounds, reconfigure fails if GitLab is stopped:
Errno::ENOENT: No such file or directory - connect(2) for /var/opt/gitlab/redis/redis.socket
Which is kinda counter-intuitive, since traditionally you make changes to the config while the instance is stopped.
But either with migrations or clean installs, the problem comes with the first GitLab upgrade:
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... pg_dump: server version: 10.4; pg_dump version: 9.6.8
pg_dump: aborting because of server version mismatch
Backup failed
[FAILED]
As it instructs you, you gotta:
sudo touch /etc/gitlab/skip-auto-migrations
So now the package will update successfully, but GitLab still won't work anyway, you gotta again:
gitlab-ctl reconfigure
To do this automatically:
yum install yum-plugin-post-transaction-actions
echo 'gitlab-ce:any:/bin/gitlab-ctl reconfigure' > /etc/yum/post-actions/gitlab-ce.action
For all the nitty-gritty details, please see: