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
rails-ext-0.3.15 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.14 lib/mongo_mapper_ext/migrate.rake
rails-ext-0.3.13 lib/mongo_mapper_ext/migrate.rake