Exported data can't be re-updated to database

The problem is that we do not take fk dependencies into account in the data import order, but instead rely on the fact that the generated chagnelog inserts the database before creating the foreign keys. In your case, you are working around that assumption…

The normal usage of liquibase is not to create tables and insert data into the, then use generateChagneLog, but rather put the data into a changelog based on your understanding of how the data works, then run liqubase update to get data into the database. Since that is the primary use case, the generateChangeLog functionality doesn’t handle all cases.

Depending on how you are wanting to use liquibase, you may need to manually move the order of the the data load changesets, or add foreign key enable/disable changeSets.


I use 2.0.1 and tested it on h2.

I have two tables, person and address. Table person has a foreign key address_id references address’s id.

I inserted some data, use command generateChangeLog to export the data, delete the original data from these two tables and use update command to re-update the data to the database and it failed because of foreign key violation.

After check the exported data xml, I found the change set to insert person is in front of change set to insert address. I think it’s a bug.