# Need help understanding preconditions and onerror / onfail

**URL:** <https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617>\
**Category:** General Discussion\
**Created:** [March 14, 2022, 6:24pm UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617 "2022-03-14T18:24:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thecrumb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/thecrumb/32/704_2.png) [@thecrumb](https://forum.liquibase.org/u/thecrumb)\
**Post date:** [March 14, 2022, 6:24pm UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617/1 "2022-03-14T18:24:51Z")

</div>

I’m trying to get preconditions working so my changelogs will alert me about issues but keep running.

Reading the docs it seems like ‘WARN’ should display a warning and continue running.

_“Sends a warning and continues executing the changeset / changelog as normal.”_

If I use CONTINUE it runs but shows nothing. If I use WARN it stops (which should be what HALT does) so I’m confused?

My changelog:

```auto
databaseChangeLog:
  - changeSet:
      id: 1.2.3.2
      author: yaml-author
      comment: This is a yaml comment
      context: yaml-context
      labels: yaml-label
      preConditions:
        - onFail: WARN
        - onError: WARN
        - not:
            - tableExists:
                - tableName: LB_person
      changes:
        - createTable:
            tableName: LB_person
            columns:
              - column:
                  name: id
                  type: int
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: firstname
                  type: varchar(50)
              - column:
                  name: lastname
                  type: varchar(50)
                  constraints:
                    nullable: false
              - column:
                  name: state
                  type: char(2)

```

It does warn me “Reason: changelog-main.yaml : Not precondition failed” but it also seems to throw an exit code which halts everything? Is that expected?

---

<div class="post-metadata">

**Author:** ![thecrumb](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/thecrumb/32/704_2.png) [@thecrumb](https://forum.liquibase.org/u/thecrumb)\
**Post date:** [March 14, 2022, 6:45pm UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617/2 "2022-03-14T18:45:23Z")

</div>

I found this in Liqubase university

```auto
Failures and errors will cause Liquibase to return non-zero exit codes.
Warnings will cause Liquibase to return exit code of zero

```

But now I’m even more confused - how do I handle these sort of issues without failing things?

---

<div class="post-metadata">

**Author:** ![daryldoak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/daryldoak/32/764_2.png) [@daryldoak](https://forum.liquibase.org/u/daryldoak)\
**Post date:** [March 15, 2022, 3:17pm UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617/3 "2022-03-15T15:17:32Z")

</div>

This chart contains a good description of each option.

> **[preconditions | Liquibase Docs](https://docs.liquibase.com/concepts/changelogs/preconditions.html?Highlight=preconditions#onFail/onError)**
>
> Reference information for using Preconditions in Liquibase. Preconditions control the execution of an update based on the state of the database and can be attached to a changelog or changeset.

If the precondition is checking to see if an object already exists or not, I would typically use MARK\_RAN to indicate the changeset is already “complete”. Then the execution will continue without an error.

---

<div class="post-metadata">

**Author:** ![alexsunny123](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@alexsunny123](https://forum.liquibase.org/u/alexsunny123)\
**Post date:** [June 11, 2022, 1:34pm UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617/4 "2022-06-11T13:34:12Z")

</div>

> [@thecrumb](#):
>
> I found this in Liqubase university
> 
> ```auto
> Failures and errors will cause Liquibase to return non-zero exit codes.
> Warnings will cause Liquibase to return exit code of zero
> 
> ```
> 
> But now I’m even more confused - how do I handle these sort of issues without failing things?

thanks my issue has been fixed.

---

<div class="post-metadata">

**Author:** ![alexsunny123](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@alexsunny123](https://forum.liquibase.org/u/alexsunny123)\
**Post date:** [February 8, 2023, 8:02am UTC](https://forum.liquibase.org/t/need-help-understanding-preconditions-and-onerror-onfail/6617/5 "2023-02-08T08:02:42Z")

</div>

> [@alexsunny123](#):
>
> > [@thecrumb](#):
> >
> > I found this in Liqubase university
> > 
> > ```auto
> > Failures and errors will cause Liquibase to return non-zero exit codes.
> > Warnings will cause Liquibase to return exit code of zero
> > 
> > ```
> > 
> > But now I’m even more confused - how do I handle these sort of issues without failing things?  
> > [Ometv](https://ometv.onl) [chatroulette](https://chatroulette.top)
> 
> thanks my issue has been fixed.

thanks my issue has been fixed.
