[SOLVED] Database Migration Fails After Upgrade

I’m running arch Linux and hadn’t updated gitlab in a while once i upgraded i ran the database migration command.
su - gitlab -s /bin/sh -c "cd '/usr/share/webapps/gitlab'; bundle-2.3 exec rake db:migrate RAILS_ENV=production --trace"
When i run it, it fails giving me a stack trace.

    su - gitlab -s /bin/sh -c "cd '/usr/share/webapps/gitlab'; bundle-2.3 exec rake db:migrate RAILS_ENV=production 
--trace"
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
TypeError: no implicit conversion of nil into String
/usr/share/webapps/gitlab/config/initializers/1_settings.rb:83:in `expand_path'
/usr/share/webapps/gitlab/config/initializers/1_settings.rb:83:in `absolute'
/usr/share/webapps/gitlab/config/initializers/1_settings.rb:405:in `block in <top (required)>'
/usr/share/webapps/gitlab/config/initializers/1_settings.rb:403:in `each'
/usr/share/webapps/gitlab/config/initializers/1_settings.rb:403:in `<top (required)>'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:652:in `block in load_config_initializer'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:166:in `instrument'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:651:in `load_config_initializer'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:615:in `each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/engine.rb:615:in `block in <class:Engine>'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `run'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:44:in `each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:44:in `tsort_each_child'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:415:in `call'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:347:in `each'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:347:in `call'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/opt/ruby2.3/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/application.rb:352:in `initialize!'
/usr/share/webapps/gitlab/config/environment.rb:5:in `<top (required)>'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/application.rb:328:in `require_environment!'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/opt/ruby2.3/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/opt/ruby2.3/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/bin/rake:22:in `load'
/usr/share/webapps/gitlab/vendor/bundle/ruby/2.3.0/bin/rake:22:in `<main>'
Tasks: TOP => db:migrate => environment

Any help or push in the right direction would be appreciated thanks.

Managed to fix this by uninstalling gitlab reinstalling and just migrating the database again something must have gotten messed up during the upgrade hope this helps anyone else that has this issue.

To me a reinstall is not a fix.I hit the same problem and I investigate further.
I modified the 1_settings.rb file to prevent the crash, then a useful log message appeared saying that my config was wrong.
In the config/gitlab.yml, my config was:

## Repositories settings
repositories:
  # Paths where repositories can be stored. Give the canonicalized absolute pathname.
  # NOTE: REPOS PATHS MUST NOT CONSTAINS ANY SYMLINK!!!
  storages: # You must have at least a `default` storage path.
    default: /var/lib/gitlab/repositories/

I changed it to:

## Repositories settings
repositories:
  # Paths where repositories can be stored. Give the canonicalized absolute pathname.
  # NOTE: REPOS PATHS MUST NOT CONSTAINS ANY SYMLINK!!!
  storages: # You must have at least a `default` storage path.
    default:
      path: /var/lib/gitlab/repositories/

Then the migration command you gave worked.

Thanks will be useful if it happens again. glad there is now an actual solution.