php - 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 evendoctrine:migration status
when i try thedoctrine: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
Answer
Solution:
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 executingmysql --version
, you will get the correct version you are currently running.
Answer
Solution:
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)."
Answer
Solution:
It works if I change theDATABASE_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
Answer
Solution:
In my case, it works when I remove : ?serverVersion=5.2 , from the url.
Answer
Solution:
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 updatedconfig/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
Answer
Solution:
you have to change theserverVersion=5.7
in .env toserverVersion=mariadb-10.4.8
Answer
Solution:
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://...yoursettings...?serverVersion=mariadb-10.4.13
Answer
Solution:
Remove the server version in .env fileDATABASE_URL=mysql://root:@127.0.0.1:3306/DB_Name
Answer
Solution:
I've addedserverVersion=mariadb-10.4.11
in the database URL string, and it worked.
Answer
Solution:
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
Answer
Solution:
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';
}
Answer
Solution:
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
Answer
Solution:
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
Answer
Solution:
Same problem here.. I "sloved" it but dont try this at home!
I removed these lines invendor\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 runmake:migration
andmigrations:migrate
.
After success migration paste the function back.
Answer
Solution:
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.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xmlhttprequest error flutter
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.