Posts Truncate database in Ruby on Rails 6
Post
Cancel

Truncate database in Ruby on Rails 6

Truncate database in Ruby on Rails 6

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

1
rails db:truncate_all

NOTE: In older versions of Rails, you can always use the database_cleaner gem. Thanks to this gem you can run DatabaseCleaner.clean_with :truncation in rails console or create a rake task on your own.

This post is licensed under CC BY 4.0 by the author.