Model association changes in production environment, specifically converting a model to polymorphic?

Posted by dustmoo on Stack Overflow See other posts from Stack Overflow or by dustmoo
Published on 2010-05-12T15:42:21Z Indexed on 2010/05/12 15:44 UTC
Read the original article Hit count: 147

Hi everyone,

I was hoping I could get feedback on major changes to how a model works in an app that is in production already.

In my case I have a model Record, that has_many PhoneNumbers.

Currently it is a typical has_many belongs_to association with a record having many PhoneNumbers.

Of course, I now have a feature of adding temporary, user generated records and these records will have PhoneNumbers too.

I 'could' just add the user_record_id to the PhoneNumber model, but wouldn't it be better for this to be a polymorphic association?

And if so, if you change how a model associates, how in the heck would I update the production database without breaking everything? >.<

Anyway, just looking for best practices in a situation like this.

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord