For this exercise, you will update your contact manager from homework #9/10 (or the one from 11 or 12) and modify the database.
Create a
hw13
directory in your repository with a copy of your app.For this homework, you will add code to modify the database. This is a common problem in a real system: you realize you need a new table, or an extra column in an existing table, or even need to modify some data. Database migration features are built in to Rails. In Django, you will need the South module:
Create a migration to add a “birthday” field to the table of contacts. It should be null by default.
Add that field to the template that displays a contact. Optional: add it to the form to create/edit a contact as well.
Read the documentation for South/Rails migrations about creating tables, as well as doing a data migrations. There is information in the South docs about data migrations. There is some scattered in the Rails docs, as well as some examples elsewhere.
A data migration is a migration that might not affect the database structure, but does modify the data. For example, you might have a “price” column that was stored with too many decimal places ($123.4567) and have a data migration round all values to two places ($123.46). At the same time, you'd probably write code so that future entries in the table are rounded properly as they are stored.
There will be no code resulting from this part of the homework.
Commit and push your work in the repository to the server.
Send an email to zju.webdev@gmail.com with the subject “Homework #13”. Include the path within your repository where we'll find your work. Be sure to include your student number in the body of the email so we find the right repository.