diff options
author | kennyj <kennyj@gmail.com> | 2012-08-01 23:16:04 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2012-08-02 00:47:54 +0900 |
commit | e35c67ae0f920011a2440210041e96659a8de985 (patch) | |
tree | 70b61e6eec4854258cb7a16de4fa32528924986a /activerecord/lib | |
parent | 083ddec719c59c75acb331c6b22a25f8f2c42c9e (diff) | |
download | rails-e35c67ae0f920011a2440210041e96659a8de985.tar.gz rails-e35c67ae0f920011a2440210041e96659a8de985.tar.bz2 rails-e35c67ae0f920011a2440210041e96659a8de985.zip |
The use_schema_cache_dump configuration moved to ActiveRecord.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 9432a70c41..672d9a4246 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -29,6 +29,8 @@ module ActiveRecord 'ActiveRecord::RecordNotSaved' => :unprocessable_entity ) + config.active_record.use_schema_cache_dump = true + rake_tasks do require "active_record/base" load "active_record/railties/databases.rake" @@ -66,6 +68,25 @@ module ActiveRecord end end + initializer "active_record.check_schema_cache_dump" do |app| + 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.dump") + + if File.file?(filename) + cache = Marshal.load File.binread filename + if cache.version == ActiveRecord::Migrator.current_version + ActiveRecord::Model.connection.schema_cache = cache + else + warn "schema_cache.dump is expired. Current version is #{ActiveRecord::Migrator.current_version}, but cache version is #{cache.version}." + end + end + end + end + end + end + initializer "active_record.set_configs" do |app| ActiveSupport.on_load(:active_record) do app.config.active_record.each do |k,v| @@ -117,21 +138,6 @@ module ActiveRecord end end - ActiveSupport.on_load(:active_record) do - if app.config.use_schema_cache_dump - filename = File.join(app.config.paths["db"].first, "schema_cache.dump") - - if File.file?(filename) - cache = Marshal.load File.binread filename - if cache.version == ActiveRecord::Migrator.current_version - ActiveRecord::Model.connection.schema_cache = cache - else - warn "schema_cache.dump is expired. Current version is #{ActiveRecord::Migrator.current_version}, but cache version is #{cache.version}." - end - end - end - end - end end end |