Search code examples
kotlinjooqddltestcontainers

How to replicate the production schema in a testcontainer using jooq?


Is it possible to initialize a database in a testcontainer using jooq programmatically at runtime rather than build time, or do I have to execute the DDL files?


Solution

  • You can use create.execute(ddl(TABLE).getSQL()) for simple cases, but if your table contains foreign keys, it is better to execute the DDL files by replacing execute's argument with a string containing the contents of the DDL files.