diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-07 16:44:50 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-07 16:44:50 -0800 |
commit | 447ecb08ca1bab594198282237c4e9a027f7a3f4 (patch) | |
tree | f294ae7de0f0246eca655ac6291b2392566f28d3 /activerecord/lib/active_record/railties | |
parent | b700153507b7d539a57a6e3bcf03c84776795051 (diff) | |
parent | 46c12172fe651980438e0b0663e2005cf3132079 (diff) | |
download | rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.tar.gz rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.tar.bz2 rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.zip |
Merge pull request #5162 from kennyj/schema_cache_dump
[Proposal] Schema cache dump
Diffstat (limited to 'activerecord/lib/active_record/railties')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index cf0092e0e3..f26989ae57 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -372,6 +372,25 @@ db_namespace = namespace :db do task :load_if_ruby => 'db:create' do db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby end + + namespace :cache do + desc 'Create a db/schema_cache.dump file.' + task :dump => :environment do + con = ActiveRecord::Base.connection + filename = File.join(Rails.application.config.paths["db"].first, "schema_cache.dump") + + con.schema_cache.clear! + con.tables.each { |table| con.schema_cache.add(table) } + open(filename, 'wb') { |f| f.write(Marshal.dump(con.schema_cache)) } + end + + desc 'Clear a db/schema_cache.dump file.' + task :clear => :environment do + filename = File.join(Rails.application.config.paths["db"].first, "schema_cache.dump") + FileUtils.rm(filename) if File.exists?(filename) + end + end + end namespace :structure do |