Doctrine 中的额外变更列生成-迁移-差异

发布于 2024-08-13 05:40:22 字数 266 浏览 1 评论 0原文

我正在不同的 yaml 模式文件之间生成迁移:即运行:

symfonydoctrine:generate-migrations-diff

生成的迁移文件包含大量未在上次模式文件更改中添加的changeColumn 调用。

例如,如果您运行generate-migrations-diff而不更改模式文件,则应该得到一个空的up()函数。但是,为我生成的函数实际上对数据库中的每个表都有一个changeColumn 调用。

我做错了什么还是这是一个错误?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦归所梦 2024-08-20 05:40:22

generate-migrations-diff 不会比较两个不同的 yaml 文件。它实际上会比较您的模型和 yaml 文件,然后根据差异生成迁移。如果您从与 yaml 和类同步的数据库开始,则进行模式更改的工作流程应该是:

  1. 更改 yaml 文件
  2. generate-migrations-diff 以将当前(已更改)yaml 与您的(不变)型号。这将在您的doctrine/migrations目录(或您的doctrine配置中设置的任何migrations_path)中生成一个迁移文件。
  3. migrate 以运行步骤 2 中创建的迁移,并修改数据库
  4. generate-models-yaml 以根据 yaml 文件生成新类。这些位于您指定生成的模型所在的位置(学说配置中的 models_path)。
  5. generate-sql 生成 SQL 文件。这将转到您的学说 sql_path 配置设置的位置。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文