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.
Why should the model be outside
Because models can be used everywhere in your project, in example, in different applications and modules.
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).
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):
age to my User model in schema.yml
./symfony doctrine:generate-migrations-diff. Migration class(-es) have been generated../symfony doctrine:migrate. Column age successfully added to table../symfony doctrine:build --all-classes. Build forms/filters/modelsThat's it. The main idea is that doctrine:generate-migrations-diff class:
schema.yml and info from (1)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?
Yes, you can add such method to User model because it's about users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With