Sha256: 83c7e62091d6d38aaa19521f0f31577b3fdac9a90b1ad7ba34e0d3cc2ac06ccb

Contents?: true

Size: 875 Bytes

Versions: 23

Compression:

Stored size: 875 Bytes

Contents

Rake::TaskManager.class_eval do
  def remove_task(task_name)
    @tasks.delete(task_name.to_s)
  end
end

def remove_task(task_name)
  Rake.application.remove_task(task_name)
end

namespace :db do
  
  remove_task 'db:migrate'
  desc "Migrate Database"
  task :migrate => :environment do
    ::Migration = MongoMapper::Migration
    Dir["#{Rails.root}/lib/db/**/*.rb"].each{|f| require f.sub(/\.rb$/, '')}
    
    database_alias = ENV['d'] || ENV['database']
    database_alias = 'accounts' if database_alias.blank?
    
    version = ENV['v'] || ENV['version']
    if version.blank?
      size = MongoMapper::Migration.definitions[database_alias].size
      highest_defined_version = size == 0 ? 0 : size - 1      
      version = highest_defined_version
    else
      version = version.to_i
    end
    
    MongoMapper::Migration.update database_alias, version
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
mongo_mapper_ext-0.2.2 lib/mongo_mapper_ext/migrate.rake
mongo_mapper_ext-0.1.1 lib/mongo_mapper_ext/migrate.rake
mongo_mapper_ext-0.1.0 lib/mongo_mapper_ext/migrate.rake
mongo_mapper_ext-0.0.1 lib/mongo_mapper_ext/migrate.rake
crystal-ext-0.0.3 lib/mongo_mapper_ext/migrate.rake
crystal-ext-0.0.2 lib/mongo_mapper_ext/migrate.rake
crystal-ext-0.0.1 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.29 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.28 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.27 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.25 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.24 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.23 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.22 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.21 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.20 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.19 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.18 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.17 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.16 lib/mongo_mapper_ext/migrate.rake