diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 6490826503..36b9b9d87b 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -341,6 +341,10 @@ module ActiveRecord ActiveRecord.default_timezone end + def maintain_test_schema # :nodoc: + ActiveRecord.maintain_test_schema + end + def reading_role # :nodoc: ActiveSupport::Deprecation.warn(<<~MSG) ActiveRecord::Base.reading_role is deprecated and will be removed in Rails 7.0. diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 279461d892..bf26aaba5f 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -651,7 +651,7 @@ module ActiveRecord end def maintain_test_schema! #:nodoc: - if ActiveRecord.maintain_test_schema + if ActiveRecord::Base.maintain_test_schema suppress_messages { load_schema_if_pending! } end end diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 8d24fa854d..5622a03bac 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -224,8 +224,15 @@ To keep using the current cache store, you can turn off cache versioning entirel configs.each do |k, v| next if k == :encryption setter = "#{k}=" - next if ActiveRecord.respond_to?(setter) - send(setter, v) + # Some existing initializers might rely on Active Record configuration + # being copied from the config object to their actual destination when + # `ActiveRecord::Base` is loaded. + # So to preserve backward compatibility we copy the config a second time. + if ActiveRecord.respond_to?(setter) + ActiveRecord.send(setter, v) + else + send(setter, v) + end end end end