Hello,
I have the following changeLog, which is run against a MySQL 5.5 instance, on a schema named “const”
-
- <databaseChangeLog
- xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
- xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
- http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
When I run this changeSet using “update”, the foreign key doesn’t get removed. When I run it in two steps (by commenting out the second changeSet during the first run), it works as expected.
Is this the designed behavior? What do I need to do to have the second changeSet?
Thanks,
Nadav
I have the same problem and it happens every time a changelog contains a ChangeSet that
creates a new table with foreign key constraints and one or more other ChangeSet(s) that use dropAllForeignKeyConstraints tag to drop all foreing key constraints from that same table.
But the problem is not caused by MySQL or missing database commit, but due to the way the class
liquibase.change.core.DropAllForeignKeyConstraintsChange is implemented.
On the validation stage, liquibase.change.core.DropAllForeignKeyConstraintsChange.generateStatements(Database)
method is called, and here there are some lazy initialization statements for the private List attribute childDropChanges: on this stage both the new table has not been created yet and private attribute childDropChanges is not initialized yet, so the private method generateChildren(Database database) is called, but it doesn’t find any foreign key constraint defined for the baseTableName declared (the table doesn’t exist yet!), so the childDropChanges List attribute is initialized, empty…
When run stage arise, the List attribute childDropChanges of DropAllForeignKeyConstraintsChange has been
inizialized, so the lazy initialization code inside generateStatements(Database) is skipped, leaving the
List childDropChanges empty, even if, in the mean time, other ChangeSet created the table and its foreign key
constraints that one expects should be dropped!
So the change run successfully with an empty list of constraint to drop, leaving the table unchanged!
I’m stuck to the 2.0.5 version due to incompatibility of new versions of Liquibase with some extensions of mine: any solutions to suggest?
Many thanks in advance
Regards
Roberto
The current codebase has removed the childDropChanges attribute. Are you able to do a local build where you remove the attribute and keep childDropChanges as a local variable in generateStatements?
You can see the current code for reference at https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/change/core/DropAllForeignKeyConstraintsChange.java
I’m not currently planning on an official 2.0.x update.
Nathan