It's possible not to run again an SQL file which fails in the past with liquibase? I tried with failOnError:false runAlways:false but no DATABASECHANGELOG entry is made.
CodePudding user response:
Depends on what you mean by (run again).
Liquibase deals with changesets. If a given ChangeSet has been run already (Has a record in DatabaseChangeLog table) can not be skipped.
However, lets say you have a changeset file that you simply dont want to run unless a specific condition matches.
Then you can use Preconditions:
Running changelogs with preconditions
There can only be one preconditions element per changelog or changeset. If you need multiple preconditions, you can use nested preconditions. Also, preconditions at the changelog level are applied to all changesets, not just those listed in the current changelog or its child changelogs.
While running the changelog or changeset with the precondition, add it to your changelog file as shown in the examples.
If your changelog is of SQL Format, then an example is below:
Currently, only the SQL check precondition is supported.
--changeset Liquibase User:1
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM primary_table
--comment: /*comments should go after preCondition. If they are located before the precondition, then Liquibase usually gives error.*/
create table primary_table (
id int primary key,
name varchar(50) not null,
address1 varchar(50),
address2 varchar(50),
city varchar(30)
)
https://docs.liquibase.com/concepts/advanced/preconditions.html
CodePudding user response:
Thanks and with
--preconditions onFail:MARK_RAN
it's working like I want