make:migration says the metadata storage is not up to date
The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.Short answer
Doctrine Migrations keeps its history in a table and refuses to work if it thinks that table has an old layout. Often the real cause is the connection: on MariaDB, DATABASE_URL needs a serverVersion that starts with mariadb-. Fix that first, then run doctrine:migrations:sync-metadata-storage.
Fix it fast
1Find out which cause you have
Look at the connection string the app really uses, and the server type behind it.
grep -n "DATABASE_URL" .env .env.local php bin/console doctrine:migrations:sync-metadata-storage2Match what you see, then jump to its fix
- 1
The sync command itself prints the same errorMariaDB is configured as if it were MySQLFix - 2
The database already has a doctrine_migration_versions table from before an upgrade of the packageThe version table was created by an older Doctrine Migrations releaseFix - 3
The table check passes in one database tool, but the command still complainsThe command talks to a different connection than you expectFix
- 1
What does the error look like?
The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Cause 1 of 3
MariaDB is configured as if it were MySQL
1Check
The bundle docs say that when the error appears on migrate, or on the suggested sync command itself, you should check the connection string and the server version. On MariaDB the serverVersion must be prefixed with mariadb-.
grep -n "serverVersion" .env .env.local config/packages/doctrine.yaml2Fix
Set the exact server version with the prefix in the connection URL.
# .env.local
DATABASE_URL="mysql://app:secret@127.0.0.1:3306/app?serverVersion=mariadb-10.4.11"3Verify
Clear the cache and run the sync command; it should finish without the error.
php bin/console cache:clear
php bin/console doctrine:migrations:sync-metadata-storageConfirmed by symfony.com
Cause 2 of 3
The version table was created by an older Doctrine Migrations release
1Check
Doctrine Migrations 3.1 added an execution_time column to the migrations table. The migrate and execute commands upgrade the table, and a separate command syncs it by hand.
composer show doctrine/migrations2Fix
Run the sync command, then your migrations.
php bin/console doctrine:migrations:sync-metadata-storage
php bin/console doctrine:migrations:migrate3Verify
make:migration and migrate now run without the message.
php bin/console make:migrationConfirmed by github.com
Cause 3 of 3
The command talks to a different connection than you expect
1Check
The bundle config has connection and em keys that choose where migrations run; em overrides connection. A value left over from a multi-database setup sends the history table to the wrong database.
cat config/packages/doctrine_migrations.yaml
php bin/console doctrine:migrations:migrate --help2Fix
Point connection (or em) at the database that holds your schema, then sync again.
# config/packages/doctrine_migrations.yaml
doctrine_migrations:
connection: default3Verify
Run the sync command against that connection.
php bin/console doctrine:migrations:sync-metadata-storageConfirmed by symfony.com
How do I stop it coming back?
- Write serverVersion in DATABASE_URL on every environment, with the mariadb- prefix when it is MariaDB.
- Run doctrine:migrations:sync-metadata-storage once after upgrading doctrine/migrations.
- Keep one connection name for migrations in doctrine_migrations.yaml.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix