Reputation: 35
I am working with classes generated by jOOQ based on a schema maintained by Liquibase. I am looking for a way to ensure that the jOOQ classes remain consistent with the actual database. The preferred approach is to create a test that can be run by our CI tool when pull requests are created.
Is there a tool to verify that the jOOQ generated definitions are still correct?
Upvotes: 1
Views: 102
Reputation: 221135
Two obvious approaches involving your build setup are:
LiquibaseDatabase
, if you're not doing anything fancy, vendor specific.A less obvious way using programmatic jOOQ API is to compare two versions of Meta
using Meta.migrateTo(Meta)
:
// This corresponds to the meta data from your live connection
Meta m1 = ctx.meta();
// This corresponds to the meta data from your generated catalog (or schema, table, etc)
Meta m2 = ctx.meta(catalog);
// This is a generated migration script between the two versions, should be empty
Queries queries = m1.migrateTo(m2);
The approach might work, though it has a lot of caveats, which are still being fixed as of jOOQ 3.14, 3.15. Work in progress can be seen here: https://github.com/jOOQ/jOOQ/projects/1, bug reports very welcome!
Upvotes: 0