Skip to content

Continuous schema updates triggered with PostgreSQL 16 due to UTF8 charset/collation platform options comparison #241

@JoDerGraf

Description

@JoDerGraf
Q A
auditor version 3.3.3 - auditor-bundle 6.2.1
PHP version 8.2
Database PostgreSQL 16

Summary

When using PostgreSQL 16 with UTF8 charset and collation, schema updates are continuously being triggered despite no actual schema changes existing.

Current behavior

The database schema is continuously being flagged for updates when using the migration system, causing unnecessary migration files to be generated. Upon debugging in the Comparator, the issue appears to be with the Platform Options - specifically with charset and collation for PostgreSQL 16.
The debug output shows that while oldColumn._platformOptions is {array[0]} (empty), newColumn._platformOptions contains {array[2]} with charset and collate both set to "UTF8".

oldColumn = {Doctrine\DBAL\Schema\Column}
_name = "ip"
_namespace = null
_quoted = false
_type = {Doctrine\DBAL\Types\StringType}
_length = {int} 45
_precision = null
_scale = {int} 0
_unsigned = false
_fixed = false
_notnull = false
_default = null
_autoincrement = false
_values = {array[0]}
_platformOptions = {array[0]}

newColumn = {Doctrine\DBAL\Schema\Column}
_name = "ip"
_namespace = null
_quoted = false
_type = {Doctrine\DBAL\Types\StringType}
_length = {int} 45
_precision = null
_scale = {int} 0
_unsigned = false
_fixed = false
_notnull = false
_default = null
_autoincrement = false
_values = {array[0]}
_platformOptions = {array[2]}
charset = "UTF8"
collate = "UTF8"

This difference in platform options causes the schema comparator to believe there's a change requiring migration, even though functionally nothing has changed.

How to reproduce

  1. Set up a Symfony 7.2 project with auditor-bundle ^6.0
  2. Configure PostgreSQL 16 database with UTF8 charset and collation
  3. Create a basic entity with auditing enabled
  4. Run bin/console doctrine:migrations:diff
  5. Apply migration
  6. Run bin/console doctrine:migrations:diff again without making any schema changes
  7. Observe that a new migration is generated despite no actual changes

Expected behavior

The schema comparator should properly handle PostgreSQL 16's default UTF8 charset and collation settings, and not flag them as differences requiring migration when no actual schema changes exist. After running a migration, subsequent doctrine:migrations:diff commands should not generate new migrations if no entity changes were made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions