Skip to content

Useful data related rake tasks

Erik Hetzner edited this page Apr 18, 2018 · 2 revisions

Useful data-related rake tasks

  • `rake db:reset` is your best friend. That gets a set of users all (e.g. author/password, editor/password, reviewer/password, admin/password), a set of 8 papers all in different states (four of which belong to author)

  • If you modify or want to re-seed nested questions then you will want to run `rake nested-questions:seed`

  • If you add new nested questions then you’ll likely add a new rake for that, e.g. `nested-questions:seed:chris-westras-new-questions` and then update `nested-questions/seed.rake` to make sure it is run when running `rake nested-questions:seed`. This task is idempotent

  • If you update seed data that you want to stay with the app you’ll want to run rake db:data:dump and it will update the db/data.yml file. That is the file used when rake db:seed is run. Changes there should be committed and kept in the PR

  • If you update JournalFactory roles or permissions you’ll want to run `rake roles-and-permissions:seed`. It will remove unnecessary permissions and make sure everything is up to date. (this task is not idempotent if you manually add roles, permissions, or permission states as they will be cleared, but it is idempotent in terms of the roles/permissions that are defined in JournalFactory).

  • rake `db:import` is wonderful for importing data from a review app, staging, RC, submit, or lean environments. I use it when I write data migrations to make sure we don’t run into data hiccups when deploying. This task takes an rake arguments, but I can never remember how to pass those in successfully so I always edit `lib/tasks/database_import.rake` and just modify the code if I want to change heroku apps.

Clone this wiki locally