Pergunta

I am currently using liquibase with SQL based changeset, and most of them contain INSERT statements. According to the documentation this type of update operation does not produce, (by the tool) automatic rollback statements.

My question is (I might be missing something), since we can declare that a certain changeset can run in the context of a DB transaction, if an error occurs during applying the changeset, can the tool (liquibase) just issue a transaction roll back for this specific changeset?

My case is that currently all these scripts are part of a development process and these scripts are not yet final, meaning that someone changes the content, and we reply them from scratch. If in a 2000 line insert script there is a error in the SQL, I would like the tool to automatically rollback the currently transaction and not commit the changes in the DB.

Many thanks for any tips

Foi útil?

Solução

During the update process, liquibase runs each changeSet in a transaction and rolls it back if there are any errors. So If you have a 2000 line insert with an error half way through it will fail as expected and roll back automatically.

What is not generated automatically is SQL to "roll back" (in this case delete) the inserts after they have been committed. If you specify a block in your changeSet, then after update successfully executes and been committed, you can later on run "liquibase rollback v2.3" and it will undo changes since the v2.3 tag. It cannot rely on the database rollback functionality because it is already committed.

It is probably a bit confusing since rollback in this case is different than the normal database use of the term "rollback" in the context of a transaction.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top