Sha256: ae76e8f687f775d210e70fff344a1d23d5a16d68d4fb02b7e6967cecb3e404f5

Contents?: true

Size: 1.73 KB

Versions: 8

Compression:

Stored size: 1.73 KB

Contents

namespace :db do
  unless Rake::Task.task_defined?("db:drop")
    desc 'Drops all the collections for the database for the current Rails.env'
    task :drop => :environment do
      MongoMapper.database.collections.select {|c| c.name !~ /system/ }.each(&:drop)
    end
  end

  unless Rake::Task.task_defined?("db:seed")
    # if another ORM has defined db:seed, don't run it twice.
    desc 'Load the seed data from db/seeds.rb'
    task :seed => :environment do
      seed_file = File.join(Rails.root, 'db', 'seeds.rb')
      load(seed_file) if File.exist?(seed_file)
    end
  end

  unless Rake::Task.task_defined?("db:setup")
    desc 'Create the database, and initialize with the seed data'
    task :setup => [ 'db:create', 'db:seed' ]
  end

  unless Rake::Task.task_defined?("db:reseed")
    desc 'Delete data and seed'
    task :reseed => [ 'db:drop', 'db:seed' ]
  end

  unless Rake::Task.task_defined?("db:create")
    task :create => :environment do
      # noop
    end
  end

  unless Rake::Task.task_defined?("db:migrate")
    task :migrate => :environment do
      # noop
    end
  end

  unless Rake::Task.task_defined?("db:schema:load")
    namespace :schema do
      task :load do
        # noop
      end
    end
  end

  unless Rake::Task.task_defined?("db:test:prepare")
    namespace :test do
      task :prepare => :environment do
        MongoMapper.connect('test')
        MongoMapper.database.collections.select {|c| c.name !~ /system/ }.each(&:drop)
        MongoMapper.connect(Rails.env)
      end
    end
  end

  desc 'Load indexes from db/indexes.rb'
  task :index => :environment do
    indexes = File.join(Rails.root, 'db', 'indexes.rb')
    load(indexes) if File.exist?(indexes)
  end
end

task 'test:prepare' => 'db:test:prepare'

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/railtie/database.rake
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/railtie/database.rake
mongo_mapper-0.12.0 lib/mongo_mapper/railtie/database.rake
lookout-mongo_mapper-0.11.3 lib/mongo_mapper/railtie/database.rake
mongo_mapper-0.11.2 lib/mongo_mapper/railtie/database.rake
jamieorc-mongo_mapper-0.11.1.1 lib/mongo_mapper/railtie/database.rake
mongo_mapper-0.11.1 lib/mongo_mapper/railtie/database.rake
mongo_mapper-0.11.0 lib/mongo_mapper/railtie/database.rake