gpt4 book ai didi

mysql - Doctrine 想要 "ALTER TABLE coo_users CHANGE id id VARCHAR(255) NOT NULL;"但每次我更新模式时都想这样做

转载 作者:可可西里 更新时间:2023-11-01 08:39:27 26 4
gpt4 key购买 nike

如果我执行 bin/console doctrine:schema:update --force 结果是:

Updating database schema...
Database schema updated successfully! "1" query was executed

每次运行 update 命令时都会执行此操作。

因此,使用 bin/console doctrine:schema:validate 我看到了:

[Mapping] OK - The mapping files are correct.
[Database] FAIL - The database schema is not in sync with the current mapping file.

Doctrine 想要执行的查询是相同的(bin/console doctrine:schema:update --dump-sql):

ALTER TABLE coo_users CHANGE id id VARCHAR(255) NOT NULL;

发生了什么事?似乎 Doctrine 想做任何修改,因为它想再次将字段 id 更改为字段 id,每次都在无限修改中。

映射

/**
* @ORM\Id
* @ORM\Column(type="string", unique=true)
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;

最佳答案

发现错误!

问题是列类型设置为 string 而它必须是 integer

它被设置为 string 因为我使用了一个需要 string 字段的自定义生成器。当我删除自定义生成器时,我没有将字段类型改回 integer,因此 Doctrine 每次都想编辑该字段。

关于mysql - Doctrine 想要 "ALTER TABLE coo_users CHANGE id id VARCHAR(255) NOT NULL;"但每次我更新模式时都想这样做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41002546/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com