Truncate database in Ruby on Rails 6

Truncate database in Ruby on Rails 6

Insteaed of chaining rails db:drop, rails db:create and rails db:migrate we are finally able to use one commend that will clean databse in case you have to seed it one more time:

rails db:truncate_all

NOTE: In older version of rails you can always use databasecleaner gem. Thanks to this gem you can run DatabaseCleaner.cleanwith :truncation in rails console or create a rake task on your own.

Leave a comment

Plain text only. Comment must be over 20 characters.

Join the newsletter

I write about Ruby on Rails, and Web programming. Join other developers in keeping up with my content. Unsubscribe whenever. Never any spam, ads, or affiliate links.