i am new to liquibase.
in the process of starting with liquibase, i created a baseline of our legacy db schema. updates are then made relative to this baseline.
i ran into errors when running the baseline + updates for the first time against an existing database consisting of just the baseline schema.
the baseline itself failed. this was due to tables already present.
i then updated the baseline to include preConditions, e.g.:
psql also confirms that the table exists:
\dt alarm List of relations Schema | Name | Type | Owner --------+-------+-------+------------ public | alarm | table | myUser (1 row)
when running this new update it failed again:
SEVERE: Preconditions Failed liquibase.exception.MigrationFailedException: Migration failed for change set changelogs/r6.10/baseline.xml::1248689548526-1::naude_r (generated): Reason: Not precondition failed : Caused By: Preconditions Failed
this was unexpected…but maybe i just do not understand how preConditions are supposed to work.
i did take a look at the code, both NotPrecondition and TableExistsPrecondition.
if a table exists then TableExistsPrecondition will not raise an exception. NotPrecondition will then error out because it expects an exception!
i was hoping that the preConditions would follow some form of boolean evaluation, i.e. not(tableExists) = not(true) = false, thus the createTable would not execute.
does anyone have any idea on how to overcome the issue?
it may make things easier if all preConditions are evaluated using booleans, e.g.
public boolean check(Database database, DatabaseChangeLog changeLog) throws PreconditionFailedException, PreconditionErrorException;
NotPrecondition would then return !precondition.check(database, changeLog); Or and And would work in similar vain.