简体   繁体   English

数据库架构与当前映射文件不同步(但它是!)

[英]The database schema is not in sync with the current mapping file (but it is !)

I just fixed some things in my code.我只是在我的代码中修复了一些东西。 I'm now trying to validate my schema我现在正在尝试验证我的架构

php bin/console doctrine:schema:validate php bin/console 原则:模式:验证

Doctrine tells me my mapping is correct but my database schema is not. Doctrine 告诉我我的映射是正确的,但我的数据库架构不是。 So I'm doing a所以我在做一个

schema:update --dump-sql架构:更新 --dump-sql

which results in the same ALTER again and again, that I already performed many times.这一次又一次地导致相同的 ALTER,我已经执行了很多次。

Here is the ALTER :这是 ALTER :

 ALTER TABLE migration_versions CHANGE version version VARCHAR(14) NOT NULL;

I did it (with --force), the entity is reflecting the change already :我做到了(使用--force),实体已经反映了变化:

**
 * MigrationVersions
 *
 * @ORM\Table(name="migration_versions")
 * @ORM\Entity
 */
class MigrationVersions
{
    /**
     * @var string
     *
     * @ORM\Column(name="version", type="string", length=14, nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $version;

I am correct right ?我是对的吧? its varchar, lenght 14...它的varchar,长度为14 ...

And so is it in my database在我的数据库中也是如此在此处输入图片说明

I don't think Im making a mistake here but I may be missing something.我不认为我在这里犯了一个错误,但我可能会遗漏一些东西。

Have you already verified that the server_version in the doctrine config file is correct?您是否已经验证了学说配置文件中的server_version是否正确? ( config/packages/doctrine.yaml in symfony5) (symfony5 中的config/packages/doctrine.yaml

It happened to me that I was using MariaDB ( version 10.4.11-MariaDB - Source distribution ) and in the file doctrine.yaml the server_version parameter had the value 5.7 .它发生在我身上,我用MariaDB的( version 10.4.11-MariaDB - Source distribution ),并在文件中doctrine.yamlserver_version参数的值为5.7 After I corrected that, the error no longer occurred.我更正后,错误不再发生。

Also you can check this question你也可以检查这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM