Sha256: b1832ef223ff35ee352277df4f096d727117667117d70351a58cc36b85edafaa

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

namespace :db do
  # @since 0.0.2
  desc "Automigrate the database. It will destroy all the data!"
  task :automigrate, :environment do |task, args|
    RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
    Rake::Task[:environment].invoke
    Rango.logger.info("[#{Rango.environment}] Migrating databases ...")
    result = DataMapper.auto_migrate!
    Rango.logger.debug("Result: #{result.inspect}")
  end

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

  # @since 0.0.2
  desc "Run migrations"
  task :migrate, :environment do |task, args|
    RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
    Rake::Task[:environment].invoke
    abort "This task isn't implemented so far! You might want to use db:automigrate or db:autoupgrade instead."
  end

  desc "Report count of objects in database"
  task :report, :environment do |task, args|
    RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
    Rake::Task[:environment].invoke
    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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rango-0.1.1.2.10 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.9 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.8 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.7 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.6 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.5 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.4 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.3 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.2 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2.1 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.2 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1.1 lib/rango/orm/tasks/datamapper.rake
rango-0.1.1 lib/rango/orm/tasks/datamapper.rake