migrations: Error `The metadata storage is not up to date` since 3.5.3

Bug Report

Q A
BC Break yes?
Version 3.5.3

Summary

I just upgraded to 3.5.3 and I have an error when running app/console doctrine:migrations:up-to-date:

In MetadataStorageError.php line 13:
                                                                                                           
  The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.                                                                                                   

Unfortunately running doctrine:migrations:sync-metadata-storage does not help. It says [OK] Metadata storage synchronized but I get the same error when running up-to-date again.

How to reproduce

  • Mysql 5.7.40
  • doctrine/dbal 3.5.2
  • doctrine/doctrine-bundle 2.8.2
  • doctrine/doctrine-migrations-bundle 3.2.2
  • Symfony 6.2

This is my metadata table dump

CREATE TABLE `migration_versions` (
  `version` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
  `executed_at` datetime DEFAULT NULL,
  `execution_time` int(11) DEFAULT NULL,
  PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Expected behavior

It should not report an issue with out-of-sync storage

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 17
  • Comments: 27 (12 by maintainers)

Most upvoted comments

Fixed by https://github.com/doctrine/dbal/releases/tag/3.5.3 (don’t get confused, it’s another package, it just happens to have the same version number)

My solution was to downgrade to 5.3.2

composer require doctrine/migrations:3.5.2

Please stop with the spam.

Our Symfony 5.4 projects are also impacted by this issue, running MariaDB 10.6.9. Downgrading doctrine/migrations to 3.5.2 fixed the issue.

@samuel-sol reading your first message, it sounds like you downgraded doctrine/migrations to 2.5.2, then upgraded again to 2.5.3, expecting the bug to be somehow fixed… if that’s the case, I suggest you read https://github.com/doctrine/migrations/issues/1302#issuecomment-1380116851 again, but slowly.

Same problem here with MySQL 8.0.25, PHP 7.4. But im use old Doctrine 2.8.0.

  • Works revert to version 3.5.2, thanks ochov1
  • Also, works solution with editing files from doctrine/DoctrineMigrationsBundle#337
  • Not works with serverVersion in my case (im use pure Doctrine without Symfony framework).

The difference is on the “_platformOptions” for me. On database ($fromTable):

[
       "charset" => "utf8mb4"
       "collation" => "utf8mb4_unicode_ci"
]

On $toTable:

[]

I would say introduced in this commit 1f5851853825ec1b71a8b1a86a2747de87c3695b

Reverting method needsUpdate() from TableMetadataStorage fix the problem on my side

    private function needsUpdate(Table $expectedTable): ?TableDiff
    {
        if ($this->schemaUpToDate) {
            return null;
        }
        $currentTable = $this->schemaManager->listTableDetails($this->configuration->getTableName());
        $diff         = $this->schemaManager->createComparator()->diffTable($currentTable, $expectedTable);

        return $diff instanceof TableDiff ? $diff : null;
    }

Same problem for me … I’m on doctrine/migrations 3.6.0

Same here. Symfony 6.2, PHP 8.1, Mariadb 10.5.15 Downgrade to 3.5.2 fixed it for the moment. Took 10 hours, 5 tantrums and 8 project restarts to find this issue -.-

@greg0ire in the dump of the TableDiff in @dmaicher’s comment above, the column appearing in changedColumns is the version column.