Skip to content

Instantly share code, notes, and snippets.

@EdwardDiehl
Forked from nithinbekal/reseed.rake
Created January 7, 2017 19:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Rake task to reset and seed Rails database
# Originally written by Justin French (2008):
# http://justinfrench.com/notebook/a-custom-rake-task-to-reset-and-seed-your-database
#
# Modified to work with Rails 4.
desc 'Raise an error unless development environment'
task :safety_check do
raise "You can only use this in dev!" unless Rails.env.development?
end
namespace :db do
desc 'Drop, create, migrate then seed the development database'
task reseed: [
'environment',
'safety_check',
'db:reset',
'db:seed'
]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment