Sha256: 38c57ff0190205b1517fad48c7a58d1e310cf74a7b57fdeed6f2e4094c203d5f
Contents?: true
Size: 1.33 KB
Versions: 38
Compression:
Stored size: 1.33 KB
Contents
namespace :db do namespace :stuff do desc "dump the tables holding seed data to db/RAILS_ENV_seed.sql. SEED_TABLES need to be defined in config/environment.rb!!!" task :dump => :environment do config = ActiveRecord::Base.configurations[RAILS_ENV] dump_cmd = "mysqldump --user=#{config['username']} --password=#{config['password']} #{config['database']} #{SEED_TABLES.join(" ")} > db/#{RAILS_ENV}_data.sql" system(dump_cmd) end desc "load the dumped seed data from db/development_seed.sql into the test database" task :load => :environment do config = ActiveRecord::Base.configurations[RAILS_ENV] system("mysql --user=#{config['username']} --password=#{config['password']} #{config['database']} < db/#{RAILS_ENV}_data.sql") end desc "load the dumped seed data from db/development_seed.sql into the test database" task :testload => :environment do config = ActiveRecord::Base.configurations['test'] system("mysql --user=#{config['username']} --password=#{config['password']} #{config['database']} < db/test_data.sql") end desc "drop the dumped seed data from db/development_seed.sql into the test database" task :drop => :environment do ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t } end end end
Version data entries
38 entries across 38 versions & 1 rubygems