DoctrineMigrationsBundle: [error] Error thrown while running command "doctrine:migrations:migrate". Message: "The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue."

I followed the tutorial from https://symfony.com/doc/current/doctrine.html. with a Local Setup of XAMPPs MySQL and a new created Symfony project.

while running the migration “php bin/console doctrine:migrations:migrate” i got the error: [error] Error thrown while running command “doctrine:migrations:migrate”. Message: “The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.”

I tried to run sync-metadata-storage command but got the same error.

After a few people got the same error and asking about on StackOverfolw I think there is a problem withe the latest Version.

The problem was solved by delete the lines 191 -195

$expectedTable = $this->getExpectedTable();

        if ($this->needsUpdate($expectedTable) !== null) {
            throw MetadataStorageError::notUpToDate();
        }

temporally from vendor\doctrine\migrations\lib\Doctrine\Migrations\Metadata\Storage\TableMetadataStorage.php. Run the command doctrine:migrations:migrate again and paste the lines back. Now it seems to works to create new entities and migrate the changes.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 18
  • Comments: 30 (6 by maintainers)

Commits related to this issue

Most upvoted comments

It works if i change the DATABASE_URL in .env

DATABASE_URL=mysql://root:@127.0.0.1:3306/testtest?serverVersion=10.4.11 to DATABASE_URL=mysql://root:@127.0.0.1:3306/testtest?serverVersion=mariadb-10.4.11

Symfony documentation suggest specifying the version number but not the database type

“There are more options in config/packages/doctrine.yaml that you can configure, including your server_version (e.g. 5.7 if you’re using MySQL 5.7), which may affect how Doctrine functions.” https://symfony.com/doc/current/doctrine.html

Very helpful for me too, thank you very much

same for me , great response btw : my fix : ?serverVersion=mariadb-10.5.8

@martinlillemets did you try with ?serverVersion=mariadb-10.4.20 in your DATABASE_URL configuration? (ref: mariadb- is missing from your example)

Same error when updating to 3.0.1 version. MariaDB server, version 10.5.5

In our case, the problem was the name of the database. It contained a hyphen (eg data-base). mysql://user:pass@127.0.0.1:3306/data-base?serverVersion=mariadb-10.5.5

Rename the database solved the problem mysql://user:pass@127.0.0.1:3306/data_base?serverVersion=mariadb-10.5.5

PS: we tried replacing the hyphen with %2D in the url string but without success

pour quoi ce changement de doctrine affecte la manière de travailler sur la nouvelle version de symfony

Sure, Looks like I have tons of packages to upgrades 😉

thank you #HashtagAssist in my .env DATABASE_URL=mysql://root:@127.0.0.1:3306/testtest?serverVersion=10.4.11 to DATABASE_URL=mysql://root:@127.0.0.1:3306/testtest?serverVersion=mariadb-10.4.11 it is working

@thePanz I checked and you are absolutely correct, i changed it and lo and behold, it works. 🤦‍♂️ I could’ve sworn i tried it multiple times, and i even had a commented out version of DATABASE_URL in my .env with correct syntax.

The first thing to try would be to run bin/console doctrine:migrations:sync-metadata-storage and go from there. That’s all I needed to do.

The solution of @HashtagAssist did the trick for me

If setting the serverVersion is not working, it means the version you are specifying is invalid, this is not the version the server is communicating with.