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