Skip to content

Instantly share code, notes, and snippets.

@EdwardDiehl
Forked from nithinbekal/reseed.rake
Created January 7, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardDiehl/beca2cabc398355b80e8c57846046164 to your computer and use it in GitHub Desktop.
Save EdwardDiehl/beca2cabc398355b80e8c57846046164 to your computer and use it in GitHub Desktop.
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