I'm using Liquibase for versioning an existing database, so I'm using
liquibase \
--logLevel=debug \
--driver=com.mysql.jdbc.Driver \
--classpath=lib/mysql-connector-java-5.1.30.jar \
--url="jdbc:mysql://127.0.0.1:3306/schema" \
--username=user \
--password=pass \
--diffTypes="data" \
--changeLogFile="./data.xml" generateChangeLog
for generating the changeset xml.
This works, but the problem is when I'm trying to run those generated changesets. I get
Cannot add or update a child row: a foreign key ...' because the exported order of changeset does not take into account the foreign keys.
My question is: Is there a command option or something that can generate the changeset in the right order or should I manually reorder the changesets to get the desired result?
Update:
Normally, the foreign keys should be and are created after the foreign key. But, in our systems, the core application creates the structure of the database and multiple client applications are populating the database with their own private data in the same database. And when we're generating the data, the data changesets are generated in the alphabetical order of the tables in the database, which may the foreign key constraints. We managed to manually arrange the changesets, but I would like to know if there is a nicer workaround for this particular situation.