Commit 4f418a1c authored by Stan Hu's avatar Stan Hu

Use a common base class to centralize access to Geo secondary DB

parent 43b89802
class Geo::BaseFdw < ActiveRecord::Base
include ::EE::Geo::GeoTrackable
class Geo::BaseFdw < Geo::TrackingBase
self.abstract_class = true
end
class Geo::BaseRegistry < ActiveRecord::Base
include ::EE::Geo::GeoTrackable
class Geo::BaseRegistry < Geo::TrackingBase
self.abstract_class = true
end
# This module is intended to centralize all database access to the secondary
# tracking database for Geo.
module Geo
class TrackingBase < ActiveRecord::Base
self.abstract_class = true
if ::Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database
end
def self.connection
raise 'Geo secondary database is not configured' unless ::Gitlab::Geo.geo_database_configured?
super
end
end
end
module EE
module Geo
module GeoTrackable
extend ActiveSupport::Concern
included do
if ::Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database
end
end
class_methods do
def self.connection
raise 'Geo secondary database is not configured' unless ::Gitlab::Geo.geo_database_configured?
super
end
end
end
end
end
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