1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Copy config.active_record.* again when ActiveRecord::Base is loaded

Otherwise initializer files with `Rails.application.active_record.*`
might break.
This commit is contained in:
Jean Boussier 2021-06-10 18:42:59 +02:00
parent 85622b949c
commit ba877bd088
3 changed files with 14 additions and 3 deletions

View file

@ -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.

View file

@ -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

View file

@ -224,11 +224,18 @@ 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)
# 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
# This sets the database configuration from Configuration#database_configuration
# and then establishes the connection.