migrate to Rails 3 (only, not compatible with Rails 2)

This commit is contained in:
Kevin Triplett 2011-01-08 12:22:15 -06:00
parent 1b516b75bd
commit f1190e06c8
4 changed files with 11 additions and 12 deletions

View File

@ -1 +1 @@
require File.dirname(__FILE__) + "/rails/init" require "create_or_update"

View File

@ -1,30 +1,30 @@
namespace :db do namespace :db do
desc "Loads initial database models for the current environment." desc "Loads initial database models for the current environment."
task :populate => :environment do task :populate => :environment do
require File.join(File.dirname(__FILE__), '/../lib', 'create_or_update') require 'create_or_update'
Dir[File.join(RAILS_ROOT, 'db', 'populate', '*.rb')].sort.each do |fixture| Dir[File.join(RAILS_ROOT, 'db', 'populate', '*.rb')].sort.each do |fixture|
load fixture load fixture
puts "Loaded #{fixture}" puts "Loaded #{fixture}"
end 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| (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 load fixture
puts "Loaded #{fixture}" puts "Loaded #{fixture}"
end end
Dir[File.join(RAILS_ROOT, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture| Dir[File.join(RAILS_ROOT, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture|
load fixture load fixture
puts "Loaded #{fixture}" puts "Loaded #{fixture}"
end end
end end
desc "Runs migrations and then loads seed data" desc "Runs migrations and then loads seed data"
task :migrate_and_populate => [ 'db:migrate', 'db:populate' ] task :migrate_and_populate => [ 'db:migrate', 'db:populate' ]
task :migrate_and_load => [ 'db:migrate', 'db:populate' ] task :migrate_and_load => [ 'db:migrate', 'db:populate' ]
desc "Drop and reset the database for the current environment and then load seed data" 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_populate => [ 'db:reset', 'db:populate']
task :reset_and_load => [ 'db:reset', 'db:populate'] task :reset_and_load => [ 'db:reset', 'db:populate']
end end

View File

@ -1 +0,0 @@
require "create_or_update"