diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-08-01 08:52:32 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-08-01 08:52:32 -0700 |
commit | 0d45d4ebc7b387edd478121f45cabb051b453eeb (patch) | |
tree | f371c7e49d0ba57628555fd56cd039b5b359d3ce /activerecord/lib/active_record | |
parent | 26c1a4a01c14627bc13d6774696a4e622c768727 (diff) | |
parent | e35c67ae0f920011a2440210041e96659a8de985 (diff) | |
download | rails-0d45d4ebc7b387edd478121f45cabb051b453eeb.tar.gz rails-0d45d4ebc7b387edd478121f45cabb051b453eeb.tar.bz2 rails-0d45d4ebc7b387edd478121f45cabb051b453eeb.zip |
Merge pull request #7224 from kennyj/move_to_ar
The use_schema_cache_dump configuration moved to ActiveRecord.
Diffstat (limited to 'activerecord/lib/active_record')
-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 |