未验证 提交 e6f95ecf 编写于 作者: E Eileen M. Uchitelle 提交者: GitHub

Merge pull request #38348 from kytrinyx/schema-cache-load-correct-file

Use correct filename for schema cache on load
......@@ -128,7 +128,14 @@ class Railtie < Rails::Railtie # :nodoc:
if config.active_record.delete(:use_schema_cache_dump)
config.after_initialize do |app|
ActiveSupport.on_load(:active_record) do
filename = File.join(app.config.paths["db"].first, "schema_cache.yml")
db_config = ActiveRecord::Base.configurations.configs_for(
env_name: Rails.env,
spec_name: "primary",
)
filename = ActiveRecord::Tasks::DatabaseTasks.cache_dump_filename(
db_config.spec_name,
schema_cache_path: db_config.schema_cache_path,
)
if File.file?(filename)
current_version = ActiveRecord::Migrator.current_version
......
......@@ -134,7 +134,7 @@ class Post < ApplicationRecord
setup_ar!
initial = [ActiveStorage::Blob, ActiveStorage::Attachment, ActiveRecord::SchemaMigration, ActiveRecord::InternalMetadata, ApplicationRecord, "primary::SchemaMigration"].collect(&:to_s).sort
assert_equal initial, ActiveRecord::Base.descendants.collect(&:to_s).sort
assert_equal initial, ActiveRecord::Base.descendants.collect(&:to_s).sort.uniq
get "/load"
assert_equal [Post].collect(&:to_s).sort, ActiveRecord::Base.descendants.collect(&:to_s).sort - initial
get "/unload"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册