Commit f10bd091 authored by Yorick Peterse's avatar Yorick Peterse

Move EE code out of Gitlab::Database

parent 206d4e2c
...@@ -3,41 +3,45 @@ ...@@ -3,41 +3,45 @@
module EE module EE
module Gitlab module Gitlab
module Database module Database
extend ::Gitlab::Utils::Override extend ActiveSupport::Concern
override :read_only? class_methods do
def read_only? extend ::Gitlab::Utils::Override
::Gitlab::Geo.secondary?
end
def healthy? override :read_only?
return true unless postgresql? def read_only?
::Gitlab::Geo.secondary?
end
!Postgresql::ReplicationSlot.lag_too_great? def healthy?
end return true unless postgresql?
# Disables prepared statements for the current database connection. !Postgresql::ReplicationSlot.lag_too_great?
def disable_prepared_statements end
config = ActiveRecord::Base.configurations[Rails.env]
config['prepared_statements'] = false
ActiveRecord::Base.establish_connection(config) # Disables prepared statements for the current database connection.
end def disable_prepared_statements
config = ActiveRecord::Base.configurations[Rails.env]
config['prepared_statements'] = false
ActiveRecord::Base.establish_connection(config)
end
override :add_post_migrate_path_to_rails override :add_post_migrate_path_to_rails
def add_post_migrate_path_to_rails(force: false) def add_post_migrate_path_to_rails(force: false)
super super
migrate_paths = Rails.application.config.paths['db/migrate'].to_a migrate_paths = Rails.application.config.paths['db/migrate'].to_a
migrate_paths.each do |migrate_path| migrate_paths.each do |migrate_path|
relative_migrate_path = Pathname.new(migrate_path).realpath(Rails.root).relative_path_from(Rails.root) relative_migrate_path = Pathname.new(migrate_path).realpath(Rails.root).relative_path_from(Rails.root)
ee_migrate_path = Rails.root.join('ee/', relative_migrate_path) ee_migrate_path = Rails.root.join('ee/', relative_migrate_path)
next if relative_migrate_path.to_s.start_with?('ee/') || next if relative_migrate_path.to_s.start_with?('ee/') ||
Rails.application.config.paths['db/migrate'].include?(ee_migrate_path.to_s) Rails.application.config.paths['db/migrate'].include?(ee_migrate_path.to_s)
Rails.application.config.paths['db/migrate'] << ee_migrate_path.to_s Rails.application.config.paths['db/migrate'] << ee_migrate_path.to_s
ActiveRecord::Migrator.migrations_paths << ee_migrate_path.to_s ActiveRecord::Migrator.migrations_paths << ee_migrate_path.to_s
end
end end
end end
end end
......
...@@ -11,10 +11,6 @@ module Gitlab ...@@ -11,10 +11,6 @@ module Gitlab
# https://dev.mysql.com/doc/refman/5.7/en/datetime.html # https://dev.mysql.com/doc/refman/5.7/en/datetime.html
MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze
class << self
prepend EE::Gitlab::Database # rubocop: disable Cop/InjectEnterpriseEditionModule
end
def self.config def self.config
ActiveRecord::Base.configurations[Rails.env] ActiveRecord::Base.configurations[Rails.env]
end end
...@@ -274,3 +270,5 @@ module Gitlab ...@@ -274,3 +270,5 @@ module Gitlab
end end
end end
end end
Gitlab::Database.prepend(EE::Gitlab::Database)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment