I created a rails model by doing
script/generate model Customer name:string address:string city:string state:string zip:integer [...]
I filled the database with 5000 customers and started building my app. Now I’ve realized my model isn’t normalized: I often have multiple customers at the same address! If I wish to do something per-address, like, say, a mailing, this causes problems. What I’d like to have is a Address model, a Customer model, and a Mailing model.
Is there a rails way to normalize an existing model, splitting it into two models? Or should I just write a script to normalize my existing data, then generate new models accordingly?
You asked about what the migration would look like. Rather than cram this in a comment reply, I created a new answer for you.
script/generate model address customer_id:integer address:string city:string state:string zip:integerResources