Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm generating migrations between different yaml schema files: i.e. running:

symfony doctrine:generate-migrations-diff

And the resulting migration file has a whole slew of changeColumn calls that weren't added in the last schema file change.

For example, if you run generate-migrations-diff without changing your schema file whatsoever, you should get an empty up() function. However, the function that results for me has a changeColumn call for virtually every table in my database.

Am i doing something wrong or is this a bug?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
507 views
Welcome To Ask or Share your Answers For Others

1 Answer

The generate-migrations-diff doesn't diff two different yaml files. It actually compares your models and your yaml file and then generates a migration based on the differences. If you start from a db that is in sync with your yaml and classes, your workflow to make schema changes should be:

  1. Change yaml file
  2. generate-migrations-diff to diff your current (changed) yaml with your (unchanged) models. This will generate a migrations file in your doctrine/migrations directory (or whatever migrations_path is set to in your doctrine config).
  3. migrate to run the migration created in step 2 and modify your database
  4. generate-models-yaml to generate new classes based on your yaml file. These go where you've specified your generated models go (models_path in your doctrine config).
  5. generate-sql to generate a SQL file. This will go where your doctrine sql_path config is set to.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...