Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JoDerGraf opened this issue Mar 10, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@JoDerGraf
Copy link

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.

@JoDerGraf JoDerGraf added the bug Something isn't working label Mar 10, 2025
@JoDerGraf
Copy link
Author

I've identified the commit that appears to be causing this issue: 2fd99aa
The commit message "fixes" is quite inadequate and provides no insight into the purpose of these changes. This commit seems to be adding specific charset and collation handling that's causing PostgreSQL schema comparisons to continuously detect differences even when there aren't any actual schema changes.
It would be helpful if the package maintainers could provide more context about why this change was made and consider a fix that prevents these false positive schema differences with PostgreSQL 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant