I'd like to ask, is there a way how to drop foreign key constraint only when it exists? My current changeset looks like this:
<changeSet author="blabla" id="10_1_1">
<comment>Drop FK DummyFK1</comment>
<dropForeignKeyConstraint constraintName="DummyFK1" baseTableName="DummyToken" />
</changeSet>
Thanks!
You need to add preConditions
. There's foreignKeyConstraintExists
built-in precondition in liquibase
.
<changeSet id="changeSetId" author="John Doe">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="DummyFK1"/>
</preConditions>
<comment>Drop FK DummyFK1</comment>
<dropForeignKeyConstraint baseTableName="DummyToken" constraintName="DummyFK1"/>
</changeSet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With