Liquibase Post Deployment Script in Oracle

29 views Asked by At

I am using .sql files for Liquibase changeset . In Pre deployment step , I am running few scripts like Disabled the Oracle jobs etc. When there is any error Liquibase Stop running next scripts.

In any case, I want run Post Deployment step scripts.

Is there any option in Liquibase for it ?

Run always sql scripts in case fail or success.

2

There are 2 answers

1
Lautert On

Liquibase does not have any post deployment solution. I can see 2 ways:

  1. You could write an extension to implement the post execution actions -> https://contribute.liquibase.com/extensions-integrations/extensions-overview/your-first-extension/
  2. Liquibase stop processing when a changeset fails unless you set failOnError=false -> https://docs.liquibase.com/concepts/changelogs/attributes/fail-on-error.html . Adding this parameter to all changesets would make it run until the end - but you will need to review the logs for the errors as liquiabse will execute successfully.
0
Alexander Pletnev On

In any case, I want run Post Deployment step scripts. Is there any option in Liquibase for it?

Yes, you can use runOrder changeset attribute:

The runOrder attribute specifies whether a changeset should be run before or after all other changesets instead of running it sequentially based on its order in the changelog. Valid values are first and last. runOrder is not supported in formatted SQL changelogs.

To run a changeset in the end, set its runOrder to last. You might need to combine it with runAlways. And you will have to change this changeset format to YAML, XML, or JSON.

Run always sql scripts in case fail or success.

That would be a bit more complex. You can combine runOrder with preConditions, runAlways, and failOnError. Also, remember to validate your rollback statements.

Alternatively, you can use your deployment pipeline capabilities to run the post-deployment actions.