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

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



Solution 1:[1]

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:[2]

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:[3]

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:[4]

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

Solution 5:[5]

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

Solution 6:[6]

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:[7]

Symfony 5.1

if you got:

Invalid platform version "maridb-10.4.13" specified. The platform version has to be specified in the format: "<major_version>.<minor_version>.<patch_version>".

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:[8]

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

Solution 9:[9]

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

Solution 10:[10]

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:[11]

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:[12]

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 13:[13]

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 14:[14]

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 15:[15]

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 16:[16]

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:[17]

just execute this command

symfony console cache:clear

it solve the problem for me a

Solution 18:[18]

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:[19]

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:[20]

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