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.1.17 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.16 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.15 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.14 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.13 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.11 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.10 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.9 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.8 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.7 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.6 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.5 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.4 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.3 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.2 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.1 lib/tasks/magic_db_tasks.rake
magic_recipes-0.1.0 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.29 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.28 lib/tasks/magic_db_tasks.rake
magic_recipes-0.0.27 lib/tasks/magic_db_tasks.rake