php - Better use of models and migration in symfony -


hey. i'm having hard time migrating changes i've done config/doctrine/schema.yml file.

i added column age user table. did php symfony doctrine:generate-migrations-diff followed php symfony doctrine:migrate .

looking in database, column age added, without deleting data.

but, /lib/model/doctrine/base/baseuser.class.php not changed, there no age field or functions age . did command php symfony doctrine:build-model . model updated/migrated too.

so wonder, way? seems lot of work, , i'm afraid miss each time doing it.

could go right phpmyadmin, add changes in database there , php symfony doctrine:build-schema , , skip migration part (two commands).

also when comes use of models, right /lib/model/doctrine/user.class.php can make functions , such user "data class"? like, making function isfemale . if not, kind of function be?

this might bad question, why model layer inside /lib/doctrine path? far have learned, keep modules inside apps, create view , controller. why should model outside. can make models without attached controller , view?

thanks.

why should model outside

because models can used everywhere in project, in example, in different applications , modules.

could go right phpmyadmin, add changes in database there , php symfony doctrine:build-schema , , skip migration part (two commands).

of course can, migrations approach track schema when deploying production or working in team.

here how use doctrine migrations (simple use-case):

  1. add column age user model in schema.yml
  2. ./symfony doctrine:generate-migrations-diff. migration class(-es) have been generated.
  3. ./symfony doctrine:migrate. column age added table.
  4. ./symfony doctrine:build --all-classes. build forms/filters/models

that's it. main idea doctrine:generate-migrations-diff class:

  1. gathers information models' structure (php-representation of schema.yml)
  2. compares schema.yml , info (1)
  3. generates migration classes based on difference

also when comes use of models, right /lib/model/doctrine/user.class.php can make functions , such user "data class"? like, making function isfemale . if not, kind of function be?

yes, can add such method user model because it's users.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -