Given this scenario:
- existent database (SQL Server, however can be of MySQL also, RDBMS doesn’t matter that much at this point) with one table tblA.
- tblA has two rows
- for migrating the data via Liquibase, a generateChangeLog call is made with parameter valued --diffTypes=data.
- the output of the call is a changelog containing one changeSet containing two insert statements.
Question: is there a way to have the output changelog containing two changesets, one for each insert statement? (if we extrapolate, each DML statement to be in it’s own changeset, so n changesets for n insert statements ) ?
The reason: for existent databases (i.e db1A) that they are used as both reference (for generating the data changelogs) and target (for later applies), we want to make sure that a particular row is inserted via Liquibase apply only if it does not already exist (for example at a first Liquibase deploy over same db1A).
This check can be made easily via a sql precondition, but this can be done at changeSet level (hence the need for “splitting” the bulk inserts into multiple changesets, each containing one insert).
As a workaround, we can use .sql with liquibase formatted sql inside (raw sql code with all the options and support we need for this task) but wanted to know for sure if there are other options out there, Liquibased ( ).
Thanks in advance for your input!
PS: what would be really cool would be if the insert change type would support if not exists functionality (check based on the PK or something user pre-defined).