From f1190e06c8cda68a7667a1d177804e5f8a34423e Mon Sep 17 00:00:00 2001 From: Kevin Triplett Date: Sat, 8 Jan 2011 12:22:15 -0600 Subject: [PATCH] migrate to Rails 3 (only, not compatible with Rails 2) --- init.rb | 2 +- {tasks => lib/tasks}/db_populate_tasks.rake | 0 {tasks => lib/tasks}/populate.rake | 20 ++++++++++---------- rails/init.rb | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) rename {tasks => lib/tasks}/db_populate_tasks.rake (100%) rename {tasks => lib/tasks}/populate.rake (83%) delete mode 100644 rails/init.rb diff --git a/init.rb b/init.rb index 2644663..28e7925 100644 --- a/init.rb +++ b/init.rb @@ -1 +1 @@ -require File.dirname(__FILE__) + "/rails/init" \ No newline at end of file +require "create_or_update" diff --git a/tasks/db_populate_tasks.rake b/lib/tasks/db_populate_tasks.rake similarity index 100% rename from tasks/db_populate_tasks.rake rename to lib/tasks/db_populate_tasks.rake diff --git a/tasks/populate.rake b/lib/tasks/populate.rake similarity index 83% rename from tasks/populate.rake rename to lib/tasks/populate.rake index 53125c7..0f35e41 100644 --- a/tasks/populate.rake +++ b/lib/tasks/populate.rake @@ -1,30 +1,30 @@ 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 + require 'create_or_update' + Dir[File.join(RAILS_ROOT, 'db', 'populate', '*.rb')].sort.each do |fixture| + load fixture 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 + load fixture puts "Loaded #{fixture}" end - Dir[File.join(RAILS_ROOT, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture| - load fixture + Dir[File.join(RAILS_ROOT, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture| + load fixture puts "Loaded #{fixture}" end end - + desc "Runs migrations and then loads seed data" task :migrate_and_populate => [ '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" task :reset_and_populate => [ 'db:reset', 'db:populate'] task :reset_and_load => [ 'db:reset', 'db:populate'] - + end \ No newline at end of file diff --git a/rails/init.rb b/rails/init.rb deleted file mode 100644 index 268a2e4..0000000 --- a/rails/init.rb +++ /dev/null @@ -1 +0,0 @@ -require "create_or_update"