mailr/lib/tasks/clear_db.rake

24 lines
629 B
Ruby
Raw Normal View History

2011-07-29 20:05:47 +02:00
namespace :db do
2011-08-24 19:20:13 +02:00
desc "Removes all users data from db"
task :remove_all_data => :environment do
users = User.all
puts "Number of users in db: #{users.size}"
puts "Deleting data....."
User.destroy_all
puts "Done"
2011-07-29 20:05:47 +02:00
end
2011-08-24 19:20:13 +02:00
desc "Deletes users data (messages,folders,contacts)"
task :remove_users_data => :environment do
users = User.all
users.each do |u|
puts "Removing folders & messages for user #{u.email}"
u.folders.destroy_all
puts "Removing contacts for user #{u.email}"
u.contacts.destroy_all
end
end
2011-07-29 20:05:47 +02:00
end