-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Version 3.4.1 & the ORM SchemaTool #5598
Comments
Thanks for the reproducers, @HypeMC. I've updated a few lines in the first one to make it compatible with both Changing the order of DROP statements for tables and sequences as you proposed seems reasonable, this is how dbal/src/Schema/Visitor/DropSchemaSqlCollector.php Lines 87 to 95 in f18aee0
Strictly speaking, the DBAL shouldn't even try to drop the sequences that are owned by some tables since they get dropped with the tables but we could address this separately.
This sounds right to me as well. |
@morozov Thank you for working on a fix for this issue, I can confirm that everything now works as expected. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Summary
Since DBAL version 3.4.1, the ORM
SchemaTool
doesn't work as expected. I have found two problems with theSchemaTool::dropDatabase()
functionality & PostgreSQL.https://github.com/doctrine/orm/blob/5283e1441cc020d526d4842c6bfa21c1a500886d/lib/Doctrine/ORM/Tools/SchemaTool.php#L842-L850
This is for example used by the LiipTestFixturesBundle.
https://github.com/liip/LiipTestFixturesBundle/blob/fac42aff90023c698e4fa44101c406e6a9208b9e/src/Services/DatabaseTools/ORMDatabaseTool.php#L111
It tries to drop sequences that don't exist:
The following SQL is generated:
The sequence
t3_id_seq
does exist, but it is removed with the drop table statement, so the drop sequence statement fails:It tries to remove the
public
schema:The following SQL is generated:
Since the
public
schema is used by thepg_trgm
extension the drop schema statement fails:Possible solutions
Changing the order of items passed to
array_merge()
inDropSchemaObjectsSQLBuilder::buildSQL()
seems to fix the sequence problem:dbal/src/SQL/Builder/DropSchemaObjectsSQLBuilder.php
Lines 29 to 32 in 94e0164
The
DropSchemaSqlCollector
did not generate drop statements forsequencesschemas, but theDropSchemaObjectsSQLBuilder
does, so maybe remove that from theDropSchemaObjectsSQLBuilder
(probably not the right solution).The text was updated successfully, but these errors were encountered: