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

Version Path
magic_recipes-0.0.26 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.25 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.24 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.23 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.22 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.21 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.20 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.19 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.18 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.17 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.16 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.15 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.14 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.13 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.12 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.11 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.10 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.9 lib/tasks/magic_db_tasks.rake