This post is inspired by http://pupeno.com/blog/really-resetting-the-database/#comment-1179. But as my blog mostly serves as a reference for my future self, I'd like to reprint this little snippet of code here as well.
namespace :db do
desc "Crush and burn the database"
task :hard_reset => :environment do
File.delete("db/schema.rb")
Rake::Task["db:drop"].execute
Rake::Task["db:create"].execute
Rake::Task["db:migrate"].execute
Rake::Task["db:seed"].execute
if !Rails.env.test?
Rake::Task["db:data"].execute
end
end
desc "Generate sample data for developing"
task :data => :environment do
Create the sample data in here
end
end
Just finishing up brewing up some fresh ground comments...