From e348af1d4c29f2aa7fb03a7910fd816850caab11 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 14 Jan 2015 09:03:25 +0100 Subject: Rescue database error in application settings if the database still doesn't exist. --- lib/gitlab/current_settings.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 5d88a601dea..22ad7ef8c8b 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -8,7 +8,7 @@ module Gitlab else fake_application_settings end - rescue ActiveRecord::NoDatabaseError + rescue ActiveRecord::NoDatabaseError, database_adapter.constantize::Error fake_application_settings end end @@ -22,5 +22,16 @@ module Gitlab sign_in_text: Settings.extra['sign_in_text'], ) end + + # We need to check which database is setup + # but we cannot assume that the database exists already. + # Not checking this will break "rake gitlab:setup". + def database_adapter + if Rails.configuration.database_configuration[Rails.env]['adapter'] == 'mysql2' + "Mysql2" + else + "PG" + end + end end end -- cgit v1.2.1