Sha256: ab9be2a7d954dc4e76bd45e491a7045d200a5d19154257f76eebc4f36c3b2163

Contents?: true

Size: 872 Bytes

Versions: 12

Compression:

Stored size: 872 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

12 entries across 12 versions & 1 rubygems

Version Path
rails-ext-0.3.12 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.11 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.10 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.9 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.8 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.6 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.5 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.4 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.3 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.2 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3.1 lib/mongo_mapper_ext/migration.rake
rails-ext-0.3 lib/mongo_mapper_ext/migration.rake