Commit 43b89802 authored by Stan Hu's avatar Stan Hu

Move Geo tracking database connection into a concern

parent 9a64ac02
class Geo::BaseFdw < ActiveRecord::Base
self.abstract_class = true
if Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database
end
include ::EE::Geo::GeoTrackable
def self.connection
raise 'Geo secondary database is not configured' unless Gitlab::Geo.geo_database_configured?
super
end
self.abstract_class = true
end
class Geo::BaseRegistry < ActiveRecord::Base
self.abstract_class = true
if Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database
end
include ::EE::Geo::GeoTrackable
def self.connection
raise 'Geo secondary database is not configured' unless Gitlab::Geo.geo_database_configured?
super
end
self.abstract_class = true
end
......@@ -5,4 +5,3 @@ module Geo
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