I have a problem. I autogenerate my changelog. I try to add some precondition on a changeset. But when i serialize mys changeset, the precondition rule doesn't appear in my XML changelog. I see only the addcolumn section
Here how i generate my changeset:
final ChangeSet changeset = new CustomChangeSet("myId", "tutu", false, true, "", "toto", "", true, ObjectQuotingStrategy.QUOTE_ALL_OBJECTS, null);
//type
final LiquibaseDataType type = new VarcharType();
type.addParameter(255);
final AddColumnConfig addColumn = new AddColumnConfig();
addColumn.setName("MyCol");
addColumn.setType(type.toString());
final AddColumnChange columnChange = new AddColumnChange();
columnChange.setTableName("MyTable");
columnChange.addColumn(addColumn);
PreconditionContainer precondition = new PreconditionContainer();
precondition.setOnFail(PreconditionContainer.FailOption.MARK_RAN.toString());
column.getTableName()));
NotPrecondition not = new NotPrecondition();
ColumnExistsPrecondition exists = new ColumnExistsPrecondition();
exists.setColumnName("MyCol");
exists.setTableName("MyTable");
not.addNestedPrecondition(exists);
precondition.addNestedPrecondition(not);
changeset.addChange(columnChange);
changeset.setPreconditions(precondition);
Ok I find a way.
First I extend the class ChangeSet and override some methods:
After I create a class which implement LiquibaseSerialization and delegates all method to PreconditionContainer:
Enjoy!