db_populate/lib/tasks/populate.rake

30 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2008-09-16 01:08:50 +00:00
namespace :db do
desc "Loads initial database models for the current environment."
task :populate => :environment do
require File.join(File.dirname(__FILE__), '/../../lib', 'create_or_update')
Dir[File.join(Rails.root, 'db', 'populate', '*.rb')].sort.each do |fixture|
load fixture
2008-09-13 13:28:17 +00:00
puts "Loaded #{fixture}"
end
(Dir[File.join(Rails.root, 'db', 'populate', Rails.env, '*.rb')] + Dir[File.join(Rails.root, 'db', 'populate', 'shared', '*.rb')]).sort{|x,y| File.basename(x) <=> File.basename(y)}.each do |fixture|
load fixture
puts "Loaded #{fixture}"
end
Dir[File.join(Rails.root, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture|
load fixture
2008-09-13 13:28:17 +00:00
puts "Loaded #{fixture}"
end
end
2008-09-16 01:08:50 +00:00
desc "Runs migrations and then loads seed data"
2008-10-12 00:05:39 +00:00
task :migrate_and_populate => [ 'db:migrate', 'db:populate' ]
2008-09-16 01:08:50 +00:00
task :migrate_and_load => [ 'db:migrate', 'db:populate' ]
2009-09-15 10:02:37 +00:00
desc "Drop and reset the database for the current environment and then load seed data"
task :reset_and_populate => [ 'db:reset', 'db:populate']
task :reset_and_load => [ 'db:reset', 'db:populate']
2008-09-13 13:28:17 +00:00
end