summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-01-14 09:03:25 +0100
committerMarin Jankovski <maxlazio@gmail.com>2015-01-14 09:03:25 +0100
commite348af1d4c29f2aa7fb03a7910fd816850caab11 (patch)
tree982bb9adab7a79eea380d93be53eec5ee7274e5e
parent01ab08125982b7c786818ffdd608e6169d0ff43d (diff)
downloadgitlab-ce-e348af1d4c29f2aa7fb03a7910fd816850caab11.tar.gz
Rescue database error in application settings if the database still doesn't exist.
-rw-r--r--lib/gitlab/current_settings.rb13
1 files changed, 12 insertions, 1 deletions
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