doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.4k stars 1.33k forks source link

Doctrine DBAL not picking up Table Comment updates #6205

Open LeonidasJP opened 8 months ago

LeonidasJP commented 8 months ago

Bug Report

Q A
DBAL Version 3.7.1
Migrations version 3.2.4

Summary

I am working on an anonymizer-tool, that works with table- and column based comments. That way the anonymizer can run plainly with DBAL, without the tool needing access to project-specific files. Therefore, I need to be able to update a table comment.

Current behaviour

DBAL is detecting a comment that is being set on a new table, and also notices the changes on a column correctly. But updating the comment on an existing table is not being detected, and leads to a "No changes detected in your mapping information." when running (symfony) bin/console doctrine:migrations:diff, even when there are changes to the table comment.

How to reproduce

Expected behaviour

At least, I expect DBAL to detect the comment being updated. Preferably, I even would like Migrations to actually write the migration query necessary

LeonidasJP commented 8 months ago

When dumping both schemas in Doctrine\Migrations\Generator\DiffGenerator::generate(), @ line 91 just after both schemas have been generated, I am presented with the following _options arrays on the TestEntity table

From schema:

Schema > _tables > anonymize.test_entity (instanceof DBAL\Schema\Table)
      #_options: array:6 [
        "create_options" => []
        "engine" => "InnoDB"
        "collation" => "utf8mb4_unicode_ci"
        "charset" => "utf8mb4"
        "autoincrement" => null
        "comment" => ""
      ]

To schema:

Schema > _tables > anonymize.test_entity (instanceof DBAL\Schema\Table)
      #_options: array:3 [
        "create_options" => []
        "charset" => "utf8mb4"
        "comment" => "Testcomment"
      ]

So, the DBAL Schema gets updated. But, Doctrine\DBAL\Schema\TableDiff seems to be unable to detect changes on tables other than renames, columns, indexes and foreign keys...

derrabus commented 8 months ago

Are you able to reproduce this issue by using DBAL APIs only?

LeonidasJP commented 8 months ago

Yes. DBAL is not producing the diff for an updated table comment, and it seems TableDiff has no ability to handle them.

I am currently away from my PC and thus unable to generate a DBAL Only example.

adrolter commented 4 months ago

Same issue here