Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DoctrineMesseger] Incompatibility with dbal 4 on Mysql #62298

Open
@Flo354

Description

@Flo354

Symfony version(s) affected

7.3

Description

Doctrine messenger uses the typeDATETIME_IMMUTABLE for the columnscreated_at,available_at,delivered_at on tablemessenger_messages.

FromSymfony\Component\Messenger\Bridge\Doctrine\Transport\Connection.php in methodaddTableToSchema

$table->addColumn('created_at', Types::DATETIME_IMMUTABLE)            ->setNotnull(true);$table->addColumn('available_at', Types::DATETIME_IMMUTABLE)            ->setNotnull(true);$table->addColumn('delivered_at', Types::DATETIME_IMMUTABLE)

This leads to the creation of the columns with a commentDC2Type to map back

Image

After migrating to DBAL 4+, the comments are not possible anymore and are ignored, with the consequence of the commandphp bin/console make:migration creating this migration:

publicfunctionup(Schema$schema):void    {// this up() migration is auto-generated, please modify it to your needs$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at DATETIME NOT NULL, CHANGE available_at available_at DATETIME NOT NULL, CHANGE delivered_at delivered_at DATETIME DEFAULT NULL');    }publicfunctiondown(Schema$schema):void    {// this down() migration is auto-generated, please modify it to your needs$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at TIMESTAMP NOT NULL COMMENT\'(DC2Type:datetime_immutable)\', CHANGE available_at available_at TIMESTAMP NOT NULL COMMENT\'(DC2Type:datetime_immutable)\', CHANGE delivered_at delivered_at TIMESTAMP DEFAULT NULL COMMENT\'(DC2Type:datetime_immutable)\'');    }

The first interesting thing is that in thedown method there isTIMESTAMP, but my column is of typeDATETIME.

The second problem is that executing the same command after will then create this over and over:

publicfunctionup(Schema$schema):void    {// this up() migration is auto-generated, please modify it to your needs$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at DATETIME NOT NULL, CHANGE available_at available_at DATETIME NOT NULL, CHANGE delivered_at delivered_at DATETIME DEFAULT NULL');    }publicfunctiondown(Schema$schema):void    {// this down() migration is auto-generated, please modify it to your needs$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at TIMESTAMP NOT NULL, CHANGE available_at available_at TIMESTAMP NOT NULL, CHANGE delivered_at delivered_at TIMESTAMP DEFAULT NULL');    }

In thedown method there is stillTIMESTAMP, while my column is of typeDATETIME

How to reproduce

Just install the package with mysql database and DBAL 3. Then migrate to DBAL 4

Possible Solution

As a workaround, in mydoctrine.yaml, I put the following:doctrine.dbal.schema_filter: ~^(?!messenger_messages)~

It will work for the migration:

 > php bin/console make:migration[WARNING] No database changes were detected. The database schema and the application mapping information are already in sync

But won't work for other commands like:

 > php bin/console doctrine:schema:validateMapping-------[OK] The mapping files are correct.Database--------[ERROR] The database schema is not in sync with the current mapping file.
 >  php bin/console doctrine:schema:update --dump-sqlALTER TABLE messenger_messages CHANGE created_at created_at DATETIME NOT NULL, CHANGE available_at available_at DATETIME NOT NULL, CHANGE delivered_at delivered_at DATETIME DEFAULT NULL;

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp