mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Postgres schema-tool fails to update existing uppercase tables #5100
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Steveb-p on GitHub (Apr 15, 2016).
Originally assigned to: @ostrolucky on GitHub.
Hello,
I wanted to migrate some of the existing database of an application to ease further development and ran into an issue where most of legacy tables are written in camelcase (cannot change these yet). While everything works fine when generating new tables from scratch, update (
orm:schema-tool:update) fails to notice that those tables already do exist and tries to create them anyway.While looking through Doctrine code to look how exactly schema-tool does this comparison to determine that a table already exists or not, I noticed that schema objects created from metadata and from existing database differ significantly in this particular case:
Existing:

Metadata:

Problem is Postgresql returns table names containing any uppercase characters with additional quoting, while metadata is - correctly in majority of cases, and conforming to a standard I guess - leaving them unquoted. Then during comparison quotation causes Doctrine to fail to notice that this table is already in
_tablesproperty and attempt to recreate the table, resulting in an error.I have modified my local Doctrine library
Doctrine\DBAL\Schema\PostgreSqlSchemaManager. changinginto
which caused the aforementioned error to disappear, and now table is updated correctly, allowing me to migrate my legacy database step by step.
I have three questions regarding this:
Note I haven't run unit tests against it yet. I didn't break my application though, so it seems.
@ostrolucky commented on GitHub (Aug 7, 2018):
In Doctrine 3.x, everything is quoted by default, which solves this issue