Created
August 28, 2012 08:24
-
-
Save marocchino/3496134 to your computer and use it in GitHub Desktop.
rake db:schema:dump_all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
namespace :schema do | |
# desc 'Dump all database schema' | |
task :dump_all => [:environment, :load_config] do | |
ActiveRecord::Base.configurations.keys.grep(/_development$/).map{|o|o.sub "_development", ""}.each do |name| | |
begin | |
filename = "#{Rails.root}/db/#{name}_schema.rb" | |
File.open(filename, 'w:utf-8') do |file| | |
ActiveRecord::Base.establish_connection("#{name}_#{Rails.env}") | |
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file) | |
end | |
rescue | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment