dropFirst, MySQL and foreignKey constraints

I am using

  • liquibase 1.9.x
  • MySQL 5.1.x

I added dropFirst to my pom.xml so that I can drop the database depending on some property that I pass on the command line to Maven.
However, when liquibase is trying to drop all objects it bumps into foreign key checks. But I want to drop everything!

Shouldn’t there be a “SET FOREIGN_KEY_CHECKS=TRUE” performed by liquibase before the database drop is begun?

Best regards /Lasse

It shouldn’t need to call SET FOREIGN_KEY_CHECKS=TRUE because the dropAll should drop all the foreign keys first.  Not all databases support such a constraint, so we try to have the dropAll be smart about the ordering.

Do you have multiple schemas that could be confusing the foreign key detection?


(Is dropAll equivalent to the dropFirst command I am trying with maven?
Yes, there are 2 schemas that shall be dropped. The schemas are handled one at a time by different blocks in the pom.xml

It crashes on DROP TABLE my_schema.report CASCADE; with error message
Cannot delete or update a parent row: a foreign key constraint fails

The table report is empty.

I see that there are 4 tables having referential constraints to my table named report. They all have delete rule RESTRICT.

First I tried changing the delete rule to NO ACTION. Same problem.

Last, I dropped all foreign key constraints. I then got the DROP TABLE to be executed without errors.

So it does not seem to be a liquibase issue, but rather a MySQL one. Why does it bother to involve constraint checking when the referenced table is empty? Strange!

Anyone got some idea?

I would still think that liquibase should drop the constraints first.  Are the tables referencing report in a different schema?