Database deployment rollback with liquibase and octopus

Does octopus provide support to liquibase for automate database deployrment? I tried to find out link where rollback scenario with octopus by using redgate readyroll, sql release and DbUp but couldn’t succeed, if possible could you please share the reference link for the same that can provide database automation deployment covering rollback scenario, it would be great if reference link uses teamcity as CI build server.

Hi Ramesh,

Thanks for getting in touch! Octopus does not naively support “Rolling back”. The only way this could be done is by creating a script to make the changes for you.
The solution here would be to create a script step that run on failure of another step or runs of the failure of the process as a whole, the script would need to contain the changes for the schema effectively rolling it back to what your changes are set to.
There are other methods you could try such as creating another project with corresponding scripts for update / rollback so if there is a failure it could be set to run the rollback.

Let me know if that helps.

Regards,
Daniel

Thanks for your reply Daniel, create a script step that run on failure of another step or runs of the failure of the process as a whole (how this process can be configured i.e steps to achieve mentioned scenario) or let me know any reference related to this, that would be very helpful, thanks again

Hi Ramesh,

Sorry for the late reply. To have a step run on failure you need to set the Run condition down the bottom of the Process page to Failure: Only run when previous step has failed
This will make it so the script step will only run when any of the previous steps encounter an error and aborts.

You can have your Rollback script use this so that if the initial deployment fails it will kickoff the rollback and manually make the changes you need to restore your Database to its original state.

Let me know how you get on.

Regards,
Daniel

Thanks Daniel for your kind support. I tried mentioned Run Condition step with of sample database deployment roll-out and roll-back project, it worked, however i would like to have more deep understanding of this, below are the few queries :

  1. What are the mainly condition when it will be run? i.e based on what type of error fatal, warning and others.
  2. This condition run based on particular step failure or db scripts (database) or powershell ( application) scripts, i have to raise this question because when i do my db deployment through Liquibase, although it successfully executed but log text gets printed in RED color represent type as INFO and ERROR both. please refer the attachment for the same.

It would be helpful if you could provide any link or reference where Run Condition example explained in detail with example.

Daniel, i tried to implement Run Condition step for database deployment project to execute rollback scripts on error in rollout project.
Please refer attached document for more detail and also let me know if there is any way i can catch steps result whether it failed or success as here in attached project octopus execute rollback project if there is error in rollout project.

DbUp_Error_Scenario.docx (2 MB)

Hi Ramesh,

In response to your previous post.

Unfortunately we do not have any documentation on this subject that would be of any help to you.
For your first question, The run on fail condition will only be triggered when it encounters a fatal error in the previous step.

As for your other question, there are methods you can take to work around this. We did come up with an idea for how this could work in practice, I will describe it below.

As the run on failure will happen for any of the previous steps and you may have specific conditions where you do not want to run the rollback scripts we have the following idea. At the end of your database step, when you are certain the db script has been run, add a variable such as ‘db-conditions-met’ and set it to true. For your rollback step the first thing you can do is check that this variable has been set before continuing. This could also be done via a file or other means, but it will give you an option to automate the db rollback as you could have failure at any point before the db step is run.

Let me know what you think, or if you have any more questions.

Regards,
Daniel

Thanks for your reply, currently i am not much confident with manual script that often used in octopus to do some activities of deployment, it would be great if you provide any reference for mentioned scenario, meanwhile i would try yo implement the same from my side.

I believe you understood my query from rollback perspective based on attachment provided by me, but there was one step that was confusing to me with respect to DbUp, ideally if there is any error in any script for e.g script000001.sql then DbUp should not make entry into SchemaVersion table which DbUp doing correctly and at the same time it should not execute any of the scipts within that script file or if some of the script executed already it should revert it i.e script file execution should not be committed until all scripts within script executed successfully.

Let me know in case any further clarification or more information required. Thanks for cooperation.

Hi Ramesh,

Octopus provides ways to help, but coming up with the how will unfortunately something you will need to figure out. We think the following gives some good information to the debate and how you should consider doing yours. Octopus itself does not follow the rollback position, rather the roll forward, so you may need to figure out your best solution here.

See below for the conversation on doing rollbacks.

Hope that helps.

Regards,
Daniel

While not addressing the question of rollbacks, I wanted to mention that there is a Community Step Template for using Liquibase available.