I'm using Liquibase on my project and need always to execute a procedure after each Liquibase updates...
Currently, the changeSet looks like this:
<changeSet id="liquibase-0" author="liquibase" runAlways="true">
<sqlFile relativeToChangelogFile="true" path="procedure/owner-changer.sql"/>
</changeSet>
How can I do ensure that this changeSet will be run as the last update operation?
Thks
Since Liquibase 3.5.0 there's new runOrder
attribute available with two possible values: first
and last
. Example for running changeSet as last one:
<changeSet id="123" author="author0" runAlways="true" runOrder="last">
<sql> ... </sql>
</changeSet>
It isn't yet described in the documentation. Release notes: http://www.liquibase.org/2016/04/liquibase-3-5-0-released.html
I would do this by splitting the changeset into two files: one that contains your "regular" changesets and the other only this single changeset. Then create a new "master" changeset that includes both, in the correct order:
<databaseChangeLog>
<include file="standard_changes.xml" relativeToChangelogFile="true"/>
<include file="change_owner.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
change_owner.xml
only contains that single changeset you have shown in your question.
This does not guarantee that it's always run last, because you could still run both change set manually in a different order, but if you always run master.xml
then you can be sure that the "change owner" is executed last.
Theoretically you could give the "master" changelog the same name as your current file. But as the filename is part of the "signature" of changeset, I wouldn't do that if you have already deployed changes through the existing file.
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