Categories
Rails

Ruby On Rails: database stuff

Since you are dealing with the database layer through the Models, you usually don’t need to worry about direct access to that layer, but here are a few commands to cleanup stuff:

bundle exec rake db:reset  // Truncates the database tables

bundle exec rake db:test:prepare // To prepare the data for tests

rake db:seed # take the data from the seed file, and puts it on the database

Note: after Rails 4.1, you don’t need to run bundle exec rake db:test:prepare after a migration, they are kept automatically sync, by this line inside spec/rails_helper.rb:

ActiveRecord::Migration.maintain_test_schema!

Leave a Reply

Your email address will not be published. Required fields are marked *