Jiss Janardhanan
Jiss Janardhanan

Reputation: 188

Liquibase : Best way to init and teardown

I have been trying to set up liquibase as our data migration tool and one requirement which came up during the discussions was that We wanted compute and log some info to a log table before and after a liquibase update is called. Is there a way in liquibase to execute some kind of setup and teardown where i can do this. Only thing i came across was to execute a custom precondition at the parent changelog file that would address may be the set up part but i am not sure if that is the best idea. Let me know if you guys are aware of a better way to do this. Thanks

Upvotes: 1

Views: 966

Answers (1)

Jiss Janardhanan
Jiss Janardhanan

Reputation: 188

Eventually ended up adding a pre-execution changeset and post execution changeset in the master changelog file before and after the included statement and set attribute runalways to true. This does the trick but not sure if there is a better solution

<changeSet id="pre-deployment" author="jj"
    runAlways="true">
    <sql>--some sql here</sql>
    <rollback>
        <sql>--same sql as this is for logging it will log the state before rollback </sql>
    </rollback>
</changeSet>

Hope this will help someone

Upvotes: 1

Related Questions