Command orm:validate-schema doesn't take #[Table(schema: 'my_schema')] into account #7023

Closed
opened 2026-01-22 15:43:19 +01:00 by admin · 3 comments
Owner

Originally created by @Aerendir on GitHub (Aug 12, 2022).

Bug Report

Q A
Version About since 2020/07

Summary

On PostgreSQL, when specifying the schema in which to create the table, the command orm:validate-schema always returns an error saying the schema is not in synch. Removing the schema parameter from the attribute solves the problem and the command correctly says the schema is in sync.

Version of PostgreSQL used: 12

Current behavior

Tested through Symfony, each time I run symfony console doctrine:schema:validate it says the schema is not in sync.
It started with this error around 2020/07 but I never put too much attention to the issue.
Now I have started to work again on the app and faced this issue again.

After many hours of debugging, I found that the problem is the schema property of the Table attribute/annotation.

It seems the command doesn't take into account the schema when evaluating the syncing of the schema.

How to reproduce

  1. Create a Symfony app
  2. Create an entity with this attribute: #[Table(name: 'yuor_name', schema: 'a_custom_schema')]
  3. symfony console doctrine:database:create
  4. symfony console doctrine:schema:create
  5. symfony console doctrine:schema:validate

The error should appear.

Expected behavior

The command return 0 (Success) as the database is correctly in synch.

Originally created by @Aerendir on GitHub (Aug 12, 2022). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | Version | About since 2020/07 #### Summary On PostgreSQL, when specifying the `schema` in which to create the table, the command `orm:validate-schema` always returns an error saying the schema is not in synch. Removing the `schema` parameter from the attribute solves the problem and the command correctly says the schema is in sync. Version of PostgreSQL used: 12 #### Current behavior Tested through Symfony, each time I run `symfony console doctrine:schema:validate` it says the schema is not in sync. It started with this error around 2020/07 but I never put too much attention to the issue. Now I have started to work again on the app and faced this issue again. After many hours of debugging, I found that the problem is the `schema` property of the `Table` attribute/annotation. It seems the command doesn't take into account the schema when evaluating the syncing of the schema. #### How to reproduce 1. Create a Symfony app 2. Create an entity with this attribute: `#[Table(name: 'yuor_name', schema: 'a_custom_schema')]` 3. `symfony console doctrine:database:create` 3. `symfony console doctrine:schema:create` 4. `symfony console doctrine:schema:validate` The error should appear. #### Expected behavior The command return `0` (Success) as the database is correctly in synch.
admin closed this issue 2026-01-22 15:43:20 +01:00
Author
Owner

@aleho commented on GitHub (Aug 16, 2022):

I started having this issue with DBAL 3.4.0.

After a bit of debugging I was able to trace it to the SEARCH_PATH implementation.
Apparently the comparator cannot handle search paths correctly if there are multiple schemas involved.

Changing the search path to all schemas involved breaks 3.3 and doesn't fix the issue on 3.4.

@aleho commented on GitHub (Aug 16, 2022): I started having this issue with DBAL 3.4.0. After a bit of debugging I was able to trace it to the `SEARCH_PATH` implementation. Apparently the comparator cannot handle search paths correctly if there are multiple schemas involved. Changing the search path to all schemas involved breaks 3.3 and doesn't fix the issue on 3.4.
Author
Owner

@aleho commented on GitHub (Aug 17, 2022):

@Aerendir Does doctrine/dbal:^3.4.1 solve this for you? Because for me it does.

@aleho commented on GitHub (Aug 17, 2022): @Aerendir Does `doctrine/dbal:^3.4.1` solve this for you? Because for me it does.
Author
Owner

@Aerendir commented on GitHub (Aug 17, 2022):

@aleho , yes, it solved the issue for me, too! 🎉
Thank you for your support!

@Aerendir commented on GitHub (Aug 17, 2022): @aleho , yes, it solved the issue for me, too! 🎉 Thank you for your support!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7023