So assume I have used rails generate to create a model and subsequently it created migrations for it.
Now it turns out I made a couple of modifications to those models (fixed up some relations). Is it possible to create migrations based off of my current model?
- I don’t want to use rails generate to generate the model again.
- I don’t want to manually write a migration.
What do you need to do with that migration?
If you need to remove or add some columns, you could use:
AddXXXToYYYandRemoveXXXFromYYY.So if you want to add a certain column to
YYYtable use:rails generate migration add_attr1_and_attr2_to dogs attr1:string attr2:stringThis would generate (rails 3.2.0):
Same goes for removing the columns:
r g migration remove_attr1_and_attr2_from_dogs attr1:string attr2:string