Reputation: 4951
Situation:
Yesterday I used gii to generate the code for my database table (mysql). I realized that my table needs a new field.
Question:
What's the convention for adding a new field in the database table? Is there a checklist of things I need to do after manually adding the new table in mysql? Or is there a one push solution via gii?
Upvotes: 3
Views: 4271
Reputation: 372
Making a diff for each an every generated code is a pain. I prefer using Giix, as it already separates the generated base from your custom code (Citation: Separated model and basemodel. Basemodel can be regenerated without overwriting your code in the model., see http://www.yiiframework.com/extension/giix/#hh8)
Upvotes: 2
Reputation: 208042
Just add the field to the database with your preferred method.
As far your generated code concerns, if you have not modified the gii generated files you can simply regenerate them, but if you have modified simply add the new logic for that field to the relevant sections you may use rules(), search(), labels etc...
You could also regenerate the content in Gii, and you can copy paste the relevant section from the Gii preview (click the name of the file).
Gii is setup to not overwrite your file, you can start a new generation and see the differences yourself. There is also a diff method in gii.
Upvotes: 10