Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I fail a liquibase migration when object fails to compile

Tags:

liquibase

I'm using Liquibase 3.1.1 to execute SQL scripts that create compiled database objects such as views, triggers, functions, and procedures.

Is there a changeset attribute that I can set to fail/abort the migration if the database object fails to compile?

For example, if I run a script that creates a trigger and that trigger fails to compile, how can I immediately stop the database migration?

like image 691
Frank Calfo Avatar asked Nov 17 '25 20:11

Frank Calfo


1 Answers

Liquibase will automatically fail the upgrade if the database throws an error executing an SQL command. You can override the behavior with the changeSet failOnError attribute, but it defaults true which stops the database update.

If you are seeing Liquibase continue even with bad trigger SQL, your database must be allowing it to be created but then throwing runtime errors when executing it. In that case, you will need a changeSet after the create that checks the view, trigger, etc. either with a precondition or a tag that calls it.

like image 52
Nathan Voxland Avatar answered Nov 19 '25 15:11

Nathan Voxland