Hey.
I’m having a hard time migrating changes I’ve done i my config/doctrine/schema.yml file.
I added the column age to the user table. Then I did a php symfony doctrine:generate-migrations-diff followed by php symfony doctrine:migrate .
Looking in my database, the column age is now added, without deleting any data.
But, my /lib/model/doctrine/base/BaseUser.class.php is not changed, there is no age field or functions for age . So I also did the command php symfony doctrine:build-model . Finally the model is updated/migrated too.
So I wonder, is this the only way? Seems like a lot of work, and I’m afraid to miss something each time doing it.
Could I go right into phpmyadmin, add changes in the database there and just do a php symfony doctrine:build-schema , and like that skip the migration part (two commands).
Also when the comes to use of models, am I right that /lib/model/doctrine/User.class.php is where I can make functions and such for my User “data class”? Like, making a function isFemale . If not, where would that kind of function be?
This might be a bad question, but why is the model layer inside the /lib/doctrine path? As far as I have learned, you keep modules inside apps, where you create your view and controller. Why should the model be outside. Like this I can make models without attached controller and view?
Thanks.
Because models can be used everywhere in your project, in example, in different applications and modules.
Of course you can, but migrations are a good approach to track your schema when deploying to production or working in team.
Here how I use doctrine migrations (simple use-case):
ageto myUsermodel inschema.yml./symfony doctrine:generate-migrations-diff. Migration class(-es) have been generated../symfony doctrine:migrate. Columnagesuccessfully added to table../symfony doctrine:build --all-classes. Build forms/filters/modelsThat’s it. The main idea is that
doctrine:generate-migrations-diffclass:schema.ymland info from (1)Yes, you can add such method to
Usermodel because it’s about users.