load 'tasks/support/rake_task_helpers.rb' namespace :db do include RakeTaskHelpers namespace :seed do desc "List all available seeds" task :list do puts seeds.inspect end desc "Up all seeds, or a seed specified in the SEED environment variable" task :up => :environment do if ENV["SEED"] seed_name = ENV["SEED"] verify_seed(seed_name) seed_klass = seeds[seed_name] AmbitiousSeeder::Seeder.up(seed_klass) else AmbitiousSeeder::Seeder.up(seeds.values) end end desc "Down the seed specific in the SEED environment variable" task :down => :environment do seed = ENV["SEED"] abort "Specify the seed to down: 'rake db:seed:down SEED=seed_name'" unless seed verify_seed(seed) seed_klass = seeds[seed] AmbitiousSeeder::Seeder.down(seed_klass) end end end