I am testing the auto rollback function for change type dropNotNullConstraint, however the auto rollback failed with error
Cannot insert the value NULL into column 'name', table 'liquibase.dbo.person'; column does not allow nulls. UPDATE fails.
Here’s what I did:
- Create a NOT NULL constraint with createTable PERSON in column NAME
- Drop the not null constraint with dropNotNullConstraint in column NAME
- My application starts running, which will create a data with null NAME (this database change is not recorded in Liquibase)
- Rollback the dropNotNullConstraint from step 2
According to Liquibase dropNotNullConstraint Documentation, it should support auto rollback. But in my case, it fails.
I can easily prevent the error by writing my own rollback script, i.e. delete the null NAME data before dropping the null constraint. However I wonder, when should I create my own rollback script? Although the change type supports auto rollback, will the auto rollback fails when some data violates the rollback action?
Much appreciated for any help.