lib/railties/hydra-migrate.rake in hydra-migrate-0.0.1 vs lib/railties/hydra-migrate.rake in hydra-migrate-0.1.0

- old
+ new

@@ -3,14 +3,17 @@ task :migrate, [:models] => :environment do |t,args| migrator = Hydra::Migrate::Dispatcher.new migrator.load_migrations(File.join(Rails.root,'db/hydra')) models = (args[:models] || 'ActiveFedora::Base').split(/[,;\s]+/) models.each do |model| - klass = model.split(/::/).inject(Module) { |k,c| k.const_find(c.to_sym) } - klass.find(:all).each do |obj| + klass = model.split(/::/).inject(Module) { |k,c| k.const_get(c.to_sym) } + klass.find_each({},{:cast=>true}) do |obj| while migrator.can_migrate? obj - $stderr.puts "Migrating #{obj.class} #{obj.pid} from #{obj.current_migration.inspect} to #{version.inspect}" - migrator.migrate! obj + migrator.migrate!(obj) do |o,m,d| + current = o.current_migration + current = 'unknown version' if current.blank? + $stderr.puts "Migrating #{o.class} #{o.pid} from #{current} to #{m[:to]}" + end end end end end end \ No newline at end of file