Commit f10bd091 authored by Yorick Peterse's avatar Yorick Peterse

Move EE code out of Gitlab::Database

parent 206d4e2c
......@@ -3,41 +3,45 @@
module EE
module Gitlab
module Database
extend ::Gitlab::Utils::Override
extend ActiveSupport::Concern
override :read_only?
def read_only?
::Gitlab::Geo.secondary?
end
class_methods do
extend ::Gitlab::Utils::Override
def healthy?
return true unless postgresql?
override :read_only?
def read_only?
::Gitlab::Geo.secondary?
end
!Postgresql::ReplicationSlot.lag_too_great?
end
def healthy?
return true unless postgresql?
# Disables prepared statements for the current database connection.
def disable_prepared_statements
config = ActiveRecord::Base.configurations[Rails.env]
config['prepared_statements'] = false
!Postgresql::ReplicationSlot.lag_too_great?
end
ActiveRecord::Base.establish_connection(config)
end
# Disables prepared statements for the current database connection.
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
def add_post_migrate_path_to_rails(force: false)
super
override :add_post_migrate_path_to_rails
def add_post_migrate_path_to_rails(force: false)
super
migrate_paths = Rails.application.config.paths['db/migrate'].to_a
migrate_paths.each do |migrate_path|
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)
migrate_paths = Rails.application.config.paths['db/migrate'].to_a
migrate_paths.each do |migrate_path|
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)
next if relative_migrate_path.to_s.start_with?('ee/') ||
Rails.application.config.paths['db/migrate'].include?(ee_migrate_path.to_s)
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'] << ee_migrate_path.to_s
ActiveRecord::Migrator.migrations_paths << 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
end
end
end
end
......
......@@ -11,10 +11,6 @@ module Gitlab
# https://dev.mysql.com/doc/refman/5.7/en/datetime.html
MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze
class << self
prepend EE::Gitlab::Database # rubocop: disable Cop/InjectEnterpriseEditionModule
end
def self.config
ActiveRecord::Base.configurations[Rails.env]
end
......@@ -274,3 +270,5 @@ module Gitlab
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