Say you want to set up a Liquibase changelog to insert some data, but you don't know the IDs of some entity, and you can express it as a query. With Liquibase's computed
column attribute, you can embed subqueries directly into seed data:
Mind the parentheses! Liquibase converts a loadData
change into an INSERT INTO ... VALUES (...)
statement, so your subqueries need to be tucked in and cozy.
Your changelog should look something like this:
And that's it! Let me know if this is useful to you! Liquibase's documentation is pretty rough in parts, and it took me a little bit to figure out how to assemble these pieces into a solution to my problem.