Tasks: Managing the points where tasks apply - MikeBlyth/mission_database GitHub Wiki
Information for developers
What if you want to add a new point to the cycle, such as “mid-term”? This requires modifying the program, so an IT person must be involved. Using “mid-term” as an example, the steps are
- Add “mid_term” as a column (field) in the database table of personnel tasks:
- Generate the migration file
rails generate migration AddMidTermToPersonnelTasks
- Edit the new migration file, which will have a name like
db/migrate/201205222145318_add_mid_term_to_personnel_tasks.rb
- Add the new column by modifying the file to read
class AddMidTermToPersonnelTasks < ActiveRecord::Migration def self.up add_column :pers_tasks, :mid_term, :boolean end
Save the filedef self.down remove_column :pers_tasks, :mid_term end end
<li>Run the migration<br> <pre> rake db:migrate</pre></li> <li>Update the test database to match <br> <pre> rake db:test:prepare</pre></li> <li>Both databases should now contain the mid_term boolean field in the personnel_tasks table.</li><br> <li>You could also simply add the new columns directly using database commands, but remember that this would have to be done for each database (the one on the server(s) as well as on the development machine). Using migrations makes it easy to propagate the changes or to undo them (rake db:migrate:rollback will undo the changes).</li><br> - Generate the migration file
- Edit the config/application_settings.yml file, adding “:mid_term” in the list in the line beginning with “pers_task_types”. It should now read something like
pers_task_types: [:pipeline, :orientation, :start_of_term, :mid_term, :end_of_term, :end_of_service]
The position of each item in the list determines its order on the form presented to the user, so it makes sense to put :mid_term between the start and end of term.
Save the file. - The “Mid term” field should now be included in the list of personnel tasks (on the development machine).
- Propagate the changes to the production database. Assuming that is still on Heroku, use these steps:
git push heroku master heroku rake db:migrate heroku ps:restart