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

Viewed 1120

I just fixed some things in my code. I'm now trying to validate my schema

php bin/console doctrine:schema:validate

Doctrine tells me my mapping is correct but my database schema is not. So I'm doing a

schema:update --dump-sql

which results in the same ALTER again and again, that I already performed many times.

Here is the ALTER :

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

I did it (with --force), the entity is reflecting the change already :

**
 * 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...

And so is it in my database enter image description here

I don't think Im making a mistake here but I may be missing something.

1 Answers

Have you already verified that the server_version in the doctrine config file is correct? (config/packages/doctrine.yaml in symfony5)

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. After I corrected that, the error no longer occurred.

Also you can check this question

Related