<NME> datamapper.rake
<BEF> # encoding: utf-8

namespace :db do
  # @since 0.0.2
  desc "Automigrate the database. It will destroy all the data!"
  task :automigrate => :environment do
    unless Rango.debug && @opts[:force]
      abort "You are in production environment. This operation will destroy all your data. If you are sure what you are doing, use thor db:automigrate --force"
    end
    Rango.logger.info("Migrating database #{Project.settings.database_name} ...")
    result = DataMapper.auto_migrate!
    Rango.logger.debug("Result: #{result.inspect}")
    Rango.logger.debug("Result: #{result.inspect}")
  end

  # @since 0.0.2
  desc "Autoupgrade the database structure. Data should stay untouched."
  task :autupgrade, :environment, :needs => :environment do |task, args|
    RACK_ENV = args.environment || ENV["RACK_ENV"] || "development"
    Rango.logger.info("[#{Rango.environment}] Upgrading databases ...")
    result = DataMapper.auto_upgrade!
    Rango.logger.debug("Result: #{result.inspect}")
  # @since 0.0.2
  desc "Run migrations"
  task :migrate => :environment do
  end

  desc "Report count of objects in database"
  task :report => :environment do
    Rango::ORM::DataMapper.models.each do |model_class|
      puts "#{model_class}: #{model_class.count}"
    end
  end
  desc "Run migrations"
  task :migrate, :environment, :needs => :environment do |task, args|
    RACK_ENV = args.environment || ENV["RACK_ENV"] || "development"
    abort "Use rake db:migrate:up[version] or db:migrate:down[version]"
  end

  namespace :migrate do
    task :load => :environment do
      begin
        require "dm-migrations/migration_runner"
      rescue LoadError
        abort "You have to install dm-migrations gem for this!"
      end
      FileList["db/migrations/*.rb"].each do |migration|
        load migration
      end
    end

    # rake db:migrate:up[version]
    # rake db:migrate:up[,environment]
    desc "Migrate up using migrations"
    task :up, :version, :environment, :needs => :load do |task, args|
      version = args.version || ENV['VERSION']
      raise ArgumentError, "You have to specify version!" if version.nil?
      migrate_up!(version)
    end

    desc "Migrate down using migrations"
    task :down, :version, :environment, :needs => :load do |task, args|
      version = args.version || ENV['VERSION']
      raise ArgumentError, "You have to specify version!" if version.nil?
      migrate_down!(version)
    end
  end
end

<MSG> Improved ORM support

<DFF> @@ -4,9 +4,6 @@ namespace :db do
   # @since 0.0.2
   desc "Automigrate the database. It will destroy all the data!"
   task :automigrate => :environment do
-    unless Rango.debug && @opts[:force]
-      abort "You are in production environment. This operation will destroy all your data. If you are sure what you are doing, use thor db:automigrate --force"
-    end
     Rango.logger.info("Migrating database #{Project.settings.database_name} ...")
     result = DataMapper.auto_migrate!
     Rango.logger.debug("Result: #{result.inspect}")
@@ -23,11 +20,13 @@ namespace :db do
   # @since 0.0.2
   desc "Run migrations"
   task :migrate => :environment do
+    abort "This task isn't implemented so far!"
   end
 
   desc "Report count of objects in database"
   task :report => :environment do
-    Rango::ORM::DataMapper.models.each do |model_class|
+    require "rango/orm/adapters/datamapper" # should be loaded in runtime, but isn't at the moment
+    Rango::ORM::Datamapper.models.each do |model_class|
       puts "#{model_class}: #{model_class.count}"
     end
   end

Improved ORM support