We have the foreign key set up on a table and would now like to delete them. In order to delete them, I have the following changeset
<changeSet author="me" id="drop-foreign-key-constraints-my_table_1">
<!-- if either or both foreign key exists, drop the foreign keys-->
<preConditions onFail="MARK_RAN">
<or>
<foreignKeyConstraintExists foreignKeyName="fk_ref_1"/>
<foreignKeyConstraintExists foreignKeyName="fk_ref_2"/>
</or>
</preConditions>
<dropAllForeignKeyConstraints baseTableName="my_table_1"/>
</changeSet>
So, the table my_table_1
has two foreign keys and if either exists, I would like to execute the changeset. I do not see any mistake in the definition, however, I see the below liquibase exception and cannot seem to figure out why this error is thrown at all.
liquibase.exception.MigrationFailedException: Migration failed for change set classpath:/create-table-my_table_1.xml::drop-foreign-key-constraints_my_table_1::me:
Reason: liquibase.exception.UnexpectedLiquibaseException: Expected to return only foreign keys for base table name: my_table_1 and got results for table: my_table_1
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:659)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:97)
at liquibase.Liquibase.update(Liquibase.java:201)
at liquibase.Liquibase.update(Liquibase.java:178)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:368)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:316)