Do I need to re-migrate whenever I change the models in Rails? Can someone tell me what migration really does? I am reading it and I am somewhat confused with the difference between the stuff inside db/migrate and the stuff inside app/models.
For example, if I add a has_one realtionship inside my model, do I need to re-migrate this? Why?
If your database changes, use a migration. If you’re just adding methods to your model, no need to have a migration.
Example:
We start out and we just have first_name, last_name. We want to store those in the database, so we have a migration that does:
/app/models/human.rb
/db/migrate/xxxxx.rb
Then we get married, so we want to track that
/app/models/human.rb
/db/migrate/xxxxx.rb
/app/models/offspring.rb
/db/migrate/xxxxx.rb
/app/models/human.rb
/app/models/human.rb