Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

make:migration says the metadata storage is not up to date

ErrorThe 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.

  • Applies to Symfony 7.4, DoctrineMigrationsBundle 3, Doctrine Migrations 3, PHP 8.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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-storage
  2. 2Match what you see, then jump to its fix

    1. 1The sync command itself prints the same errorMariaDB is configured as if it were MySQLFix
    2. 2The 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. 3The table check passes in one database tool, but the command still complainsThe command talks to a different connection than you expectFix

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.yaml

2Fix

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-storage

Confirmed by symfony.com

Did this fix it?

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/migrations

2Fix

Run the sync command, then your migrations.

php bin/console doctrine:migrations:sync-metadata-storage
php bin/console doctrine:migrations:migrate

3Verify

make:migration and migrate now run without the message.

php bin/console make:migration

Confirmed by github.com

Did this fix it?

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 --help

2Fix

Point connection (or em) at the database that holds your schema, then sync again.

# config/packages/doctrine_migrations.yaml
doctrine_migrations:
    connection: default

3Verify

Run the sync command against that connection.

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

Confirmed by symfony.com

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.