Skip to content

Commit

Permalink
don't run seeds twice (mongoid already defines db:seed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Visnu Pitiyauvath committed Oct 28, 2010
1 parent 8da56f1 commit 842b273
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/mongoid_rails_migrations/mongoid_ext/railties/database.rake
Expand Up @@ -4,10 +4,13 @@ namespace :db do
Mongoid.master.collections.each {|col| col.drop_indexes && col.drop unless ['system.indexes', 'system.users'].include?(col.name) }
end

desc 'Load the seed data from db/seeds.rb'
task :seed => :environment do
seed_file = File.join(Rails.application.root, 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
if not 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.application.root, 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
end
end

desc 'Create the database, and initialize with the seed data'
Expand Down Expand Up @@ -79,4 +82,4 @@ namespace :db do
# Stub out for MongoDB
end
end
end
end

0 comments on commit 842b273

Please sign in to comment.