Error 500 after upgrading from 8.5.x to 8.6.x (docker)

After upgrading using "docker", many pages display an error 500.

I was running version 5.8.x using docker (installation done using the official docker image from GitLab).
I followed the upgrade instruction for docker/gitlab as per official documentation but many pages show error 500.

I found the cause: the database migration failed. And when running it manually I get:

gitlab-rake db:migrate
== 20160226114608 AddTrigramIndexesForSearching: migrating ====================
-- execute("SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;")
   -> 0.0201s
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

You must enable the pg_trgm extension. You can do so by running "CREATE EXTENSION pg_trgm;" as a PostgreSQL super user, this must be done for every GitLab database. For more information see http://www.postgresql.org/docs/current/static/sql-createextension.html

What I did to solve the issue is connect to the container as user gitlab-psql and run the following commands:

$ export PGHOST="/var/opt/gitlab/postgresql"
$ psql gitlabhq_production
psql (9.2.15)
Type "help" for help.

gitlabhq_production=# CREATE EXTENSION pg_trgm;
CREATE EXTENSION

I then reconfigure and restart the container. All is working fine.

As per request, I'm adding @tmaczukin in copy. :-)