Order of insert statements

When I export data with ‘<span’ option is it possible to generate inserts in specific order that does not violate foreign keys. Later on when I run this changeset I get foreign key violation because the order is not ideal. If not, can I use any other options?
I’m trying to keep reference DB data version controlled. It has to exist in all databases.
Thank you

The only solution I could come up with is to break inserts into separate files - 1 file per table and define execution order manually. This is too much work though. Maybe liquibase has this feature, can someone point me to any links please?

There isn’t anything in the diff/snapshot functionality to manage the ordering of inserts. The main reason is because data diff is enough outside the primarily scope of liquibase that it doesn’t make sense to start dealing with all the difficult logic that would be required to figure the correct insertion order (which may not be possible, if you have circular references). When you do a snapshot generation, we include the data insert before the FK creation so it will load correctly. Does your database have the ability to enable/disable constraint checking before/after you do your load?


 I think an option is like you say to play with constraints. If we use a single changeset/transaction and initially differed constraints then load would succeed, but it can contradict DB user policy.
Probably, the best is to disable/drop constraints before the load and enable/create them after.

When I run liquibase cmd help I don’t see option --diffTypes. Are there any other ways/commands to export data and where can I read more about it?

Thank you,

I see that is missing from the command line help.


You can pass a comma-separated list of what to diff, choosing from:

tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, sequences, data

By default it includes everything except data. http://www.liquibase.org/manual/diff gives info on the parameter too.