half-working changesets not treated atomically

If you run a half-broken changeset (e.g. a single changeset with two refactorings one of which has an error), the working part of the changeset will be applied and the broken part will fail.  The changelog will not be updated, so future runs will try to rerun changeset, but fail because the working part is already applied.


I would think it would treat a changeset atomically, and roll it back if it was not able to complete it – the following changeset causes this behavior:


  1. <?xml version="1.0" encoding="UTF-8"?>

  2. <databaseChangeLog
  3.   xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  4.   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
  6.          http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">


  7.      
  8.          
  9.      
  10.      
  11.      
  12.          
  13.      

The resulting table has the working column, but not the notworking column, and will fail every time afterward, even when corrected, because the working part of the changeset was already applied.

Liquibase tries to run each changeSet in a transaction (including the insert into databasechangelog) but the trouble is that on many databases DML statements like alter table are auto-committing and there is nothing we can do about that.


It depends on the database, but a good rule of thumb is that any changes except insert/update/delete commands should be in their own changesets.


Nathan

Fair enough re: DDLs, I will bear in mind your rule of thumb.


I tried a similar scenario (below) with just DML statements and it behaved as expected - a changeset with one working insert and one failing will result in no records being inserted – thanks!


  1.     ID is primary key.  Username is unique.  This will violate the PK constraint.