Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

PhpSymfonyError HandlingMetadata

Php Problem Overview


I keep getting this problem everytime i try to migrate using the commandline: php bin/console make:migration or even doctrine:migration status when i try the doctrine:migration:sync-metadata-storage as they tell me I still get the same error message.

I'm currently learning symfony and have been following a guide but I get this problem somehow Symfony 4.4 php 7.2

Php Solutions


Solution 1 - Php

Try changing the DATABASE_URL in .env from

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

Original Answer: https://github.com/doctrine/DoctrineMigrationsBundle/issues/337#issuecomment-645390496

For MariaDB you will need the full semver compat version: Major.Minor.Patch. By executing mysql --version, you will get the correct version you are currently running.

Solution 2 - Php

For me was enough prefixing the server version with mariadb-x.x.x. It fixed the issue.

"If you are running a MariaDB database, you should prefix the serverVersion with mariadb- (ex: mariadb-10.2.12)."

https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url

Solution 3 - Php

It works if I change the DATABASE_URL in .env

From:

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

Solution 4 - Php

In my case, it works when I remove : ?serverVersion=5.2 , from the url.

Solution 5 - Php

you have to change the serverVersion=5.7 in .env to serverVersion=mariadb-10.4.8

Solution 6 - Php

I ran into the same issue after upgrading to Doctrine migrations 3

Seems that a lot of stuff has changed including the table name where migration versions are stored :(

So I updated config/packages/doctrine_migrations.yaml, created a new (blank) migration, cleared the cache (just in case) and everything went just fine :)

doctrine_migrations:
migrations_paths:
    # namespace is arbitrary but should be different from App\Migrations
    # as migrations classes should NOT be autoloaded
    'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
storage:
    # Default (SQL table) metadata storage configuration
    table_storage:
        table_name: 'migration_versions'
        version_column_name: 'version'
        version_column_length: 1024
        executed_at_column_name: 'executed_at'
        execution_time_column_name: 'execution_time'

BTW. Docs are up to date ;) https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html

Solution 7 - Php

Symfony 5.1

if you got:

Invalid platform version "maridb-10.4.13" specified. The platform version has to be specified in the format: "..".

just do one of

config/doctrine.yaml

doctrine:
  dbal:
    server_version: 'mariadb-10.4.13'

or in configuration file .env

DATABASE_URL=mysql://databaseUsername:UserPassword@localhost:3306/databaseName?serverVersion=mariadb-10.4.13

Solution 8 - Php

Remove the server version in .env file DATABASE_URL=mysql://root:@127.0.0.1:3306/DB_Name

Solution 9 - Php

I've added serverVersion=mariadb-10.4.11 in the database URL string, and it worked.

Solution 10 - Php

for me it worked with me when i removed "?serverVersion=5.7" in .env file

from: DATABASE_URL="mysql://root:@127.0.0.1:3306/centre?serverVersion=5.7"

to DATABASE_URL="mysql://root:@127.0.0.1:3306/centre"

Solution 11 - Php

I have the same problem it is because of the new version of doctrine migration 3.0

php bin/console  debug:config DoctrineMigrationsBundle 

https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html

Solution 12 - Php

Same problem here.. I "sloved" it but dont try this at home!

I removed these lines in vendor\doctrine\migrations\lib\Doctrine\Migrations\Metadata\Storage\TableMetadataStorage.php start on line 191

$expectedTable = $this->getExpectedTable();

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

Then run make:migration and migrations:migrate. After success migration paste the function back.

Solution 13 - Php

I temporary resolved this problem by modifying the file: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php

changed method diffColumn:

    // This is a very nasty hack to make comparator work with the legacy json_array type, which should be killed in v3
    if ($this->isALegacyJsonComparison($properties1['type'], $properties2['type'])) {
        array_shift($changedProperties);

        $changedProperties[] = 'comment';
    }

    //////////////////////////////////////////////////////////////////
    // This is my change for fix problem//////////////////////////////
    //////////////////////////////////////////////////////////////////
    if ($properties1['default'] === 'NULL') {
        $properties1['default'] = null;
    }
    if ($properties2['default'] === 'NULL') {
        $properties2['default'] = null;
    }
    /////////////////////////////////////////////////////////////////


    // Null values need to be checked additionally as they tell whether to create or drop a default value.
    // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
    if (($properties1['default'] === null) !== ($properties2['default'] === null)
        || $properties1['default'] != $properties2['default']) {
        $changedProperties[] = 'default';
    }

Solution 14 - Php

https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html

follow the instructions to the letter > composer require doctrine/doctrine-migrations-bundle

> php bin/console doctrine:migrations:generate

> php bin/console doctrine:migrations:status --show-versions

> php bin/console doctrine:migrations:migrate

everything worked for me

Solution 15 - Php

If you upgraded doctrine/doctrine-migrations-bundle to version 3, this solution worked for me:

Just run: php bin/console doctrine:migrations:sync-metadata-storage

Solution 16 - Php

In your .env file you can use a default settings pattern:

DATABASE_URL=mysql://db-username:[email protected]/db-name

But you need to configure server_version in doctrine.yaml

An example configuration can look like this:

doctrine:
    dbal:
        driver: 'pdo_mysql'
        server_version: 'mariadb-10.5.8-focal'
        charset: UTF8
        url: '%env(resolve:DATABASE_URL)%'

In my case, it's mariadb-10.5.8-focal.

Solution 17 - Php

just execute this command

>> symfony console cache:clear

it solve the problem for me a

Solution 18 - Php

In my case (MariaDB 10.7.3) setting ?serverVersion=mariadb-10.7.3 didn't help.

I had to uninstall MariaDB 10.7.3 and install MySQL Community 8.0.28 instead, and then changed DATABASE_URL to ?serverVersion=8.0.28

Only switching from MariaDB to MySQL Community fixed this problem for me.

Solution 19 - Php

change

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

Solution 20 - Php

in your .env file at the database line remove everything after the database name. This should fix the problem!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAziz BouaouinaView Question on Stackoverflow
Solution 1 - PhpMees van WelView Answer on Stackoverflow
Solution 2 - PhputidevidView Answer on Stackoverflow
Solution 3 - PhpMohammad AliView Answer on Stackoverflow
Solution 4 - Phpjally-phView Answer on Stackoverflow
Solution 5 - PhpMousrootView Answer on Stackoverflow
Solution 6 - PhpelkukuView Answer on Stackoverflow
Solution 7 - PhpzooreView Answer on Stackoverflow
Solution 8 - PhpkhadijaiigView Answer on Stackoverflow
Solution 9 - PhpTheTurTel500View Answer on Stackoverflow
Solution 10 - Phpfathi mhiriView Answer on Stackoverflow
Solution 11 - PhpbfxView Answer on Stackoverflow
Solution 12 - Phphashtag-assistView Answer on Stackoverflow
Solution 13 - PhpildarView Answer on Stackoverflow
Solution 14 - Phpbelmanh dubienView Answer on Stackoverflow
Solution 15 - PhpSamuel VicentView Answer on Stackoverflow
Solution 16 - PhpŁukasz D. TulikowskiView Answer on Stackoverflow
Solution 17 - PhpyesserView Answer on Stackoverflow
Solution 18 - PhpIlyichView Answer on Stackoverflow
Solution 19 - PhpCheikh Saliou TALLAView Answer on Stackoverflow
Solution 20 - PhpStephane LefebvreView Answer on Stackoverflow