summaryrefslogtreecommitdiff
path: root/lib/gitlab/database.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-08-18 14:26:23 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-08-29 13:02:44 +0200
commit5eab624d3ce7500b3cc19230b5ce86125b88015b (patch)
treecbfd2c470c9009fce1449a837d60058bed026aa0 /lib/gitlab/database.rb
parent9e7e0496ff639d1eec65dcbf1b51edb2262456e2 (diff)
downloadgitlab-ce-5eab624d3ce7500b3cc19230b5ce86125b88015b.tar.gz
Improve migrations using triggerscheck-trigger-permissions-mysql
This adds a bunch of checks to migrations that may create or drop triggers. Dropping triggers/functions is done using "IF EXISTS" so we don't throw an error if the object in question has already been dropped. We now also raise a custom error (message) when the user does not have TRIGGER privileges. This should prevent the schema from entering an inconsistent state while also providing the user with enough information on how to solve the problem. The recommendation of using SUPERUSER permissions is a bit extreme but we require this anyway (Omnibus also configures users with this permission). Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36633
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index e001d25e7b7..a6ec75da385 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -9,6 +9,14 @@ module Gitlab
ActiveRecord::Base.configurations[Rails.env]
end
+ def self.username
+ config['username'] || ENV['USER']
+ end
+
+ def self.database_name
+ config['database']
+ end
+
def self.adapter_name
config['adapter']
end