Skip to content

Instantly share code, notes, and snippets.

@jasonrudolph
Created October 3, 2008 00:02
Show Gist options
  • Save jasonrudolph/14478 to your computer and use it in GitHub Desktop.
Save jasonrudolph/14478 to your computer and use it in GitHub Desktop.
namespace :db do
namespace :data do
desc "Load data into current environment"
task :load => [:environment, 'db:drop', 'db:create'] do
db = ActiveRecord::Base.configurations[RAILS_ENV]
%x( mysql -u #{db['username']} --password=#{db['password']} #{db['database']} < "#{RAILS_ROOT}/db/dump/data.sql" )
end
desc "Dump current database schema and data to file"
task :dump => :environment do
db = ActiveRecord::Base.configurations[RAILS_ENV]
%x( mysqldump -u #{db['username']} --password=#{db['password']} #{db['database']} > "#{RAILS_ROOT}/db/dump/data.sql" )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment