mailr/lib/tasks/clear_db.rake

24 lines
632 B
Ruby
Raw Normal View History

2012-03-30 19:31:23 +02:00
namespace :mailr do
2012-03-24 13:23:34 +01: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"
end
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
end