DEV: Compatibility with Discourse on Rails 6.1 (#21)

DEV: Compatibility with Discourse on Rails 6.1 (#21)

diff --git a/.discourse-compatibility b/.discourse-compatibility
new file mode 100644
index 0000000..ce6df33
--- /dev/null
+++ b/.discourse-compatibility
@@ -0,0 +1 @@
+2.7.0.beta6: b3f511e1d2bcb7cedb0bf6c582efbda0a5488bd3
diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index e06aaf0..682571b 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -161,7 +161,7 @@ module DiscoursePrometheus::InternalMetric
     end
 
     def test_postgres(master: true)
-      config = ActiveRecord::Base.connection_config
+      config = ActiveRecord::Base.connection_db_config.configuration_hash
 
       unless master
         if config[:replica_host]
diff --git a/spec/lib/internal_metric/global_spec.rb b/spec/lib/internal_metric/global_spec.rb
index cdbfdd1..20b2c29 100644
--- a/spec/lib/internal_metric/global_spec.rb
+++ b/spec/lib/internal_metric/global_spec.rb
@@ -112,12 +112,14 @@ module DiscoursePrometheus::InternalMetric
 
     describe 'when a replica has been configured' do
       before do
-        config = ActiveRecord::Base.connection_config
+        config = ActiveRecord::Base.connection_db_config.configuration_hash.dup
 
         config.merge!(
           replica_host: 'localhost',
           replica_port: 1111
         )
+        ActiveRecord::Base.connection.disconnect!
+        ActiveRecord::Base.establish_connection(config)
       end
 
       it 'should collect the right metrics' do

GitHub sha: 0d47e639

This commit appears in #21 which was approved by CvX. It was merged by OsamaSayegh.