testcontainers-jooq-codegen-maven-plugin
testcontainers-jooq-codegen-maven-plugin copied to clipboard
Feature: Support for `TC_INITSCRIPT` parameter
Hey, thanks for this plugin, it's a neat quality of life & code improvement!
While trying to bring this goodie to an internal project I noticed that the JDBC connection parameter TC_INITSCRIPT (and TC_INITFUNCTION) are not mentioned / covered by the configuration options.
I'm specifically referring to the case when one does not wish to connect to a pre-existing container and thus does not provide a <jooq><jdbc>...</jdbc></jooq> block.
Did I simply miss this in the documentation? If not, could this be supported with relative ease?
Possibly naively speaking, I would add this as a nested configuration option e.g.
<database>
<type>POSTGRES</type>
<init_script>/../../docker/postgres/01_site.sql</init_script>
</database>
Happy to look into creating a PR
Please feel free for pull request
My use case turned out to be covered by the existing DB user credentials options. I think it's better to wait for more interest in this feature before increasing the API surface. Up to you wether you want to leave the issue open for that purpose.
@eddumelendez
Currently, the suggested approach is using copy files instead due to most of the images provides a fresh initialization folder.
Could you please clarify what 'copy file' means? Is it about using 'Initialization scripts' of a DB container? Like this for PG:
If you would like to do additional initialization in an image derived from this one, add one or more *.sql, *.sql.gz, or *.sh scripts under /docker-entrypoint-initdb.d (creating the directory if necessary).
MySQL and MariaDB:
Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d
If I understand the proposal correctly, the plugin should accept list of files and copy them into the init folder of the container. Is that correct assumption?
Config could look like
<copy>
<entries>
<entry>
<sourceFile>filesystem:${project.basedir}/src/test/resources/db/init.sql</sourceFile>
<containerPath>/docker-entrypoint-initdb.d/</containerPath>
</entry>
<entry>
<sourceFile>classpath:db/postgres/init.sh</sourceFile>
<containerPath>/docker-entrypoint-initdb.d/123.sh</containerPath>
</entry>
</entries>
</copy>
Current approach in the PR just mimics initScript mechanism built into JdbcDatabaseContainer of Testcontainers.
@eddumelendez was referring to using the Copy API. I think your config proposal makes sense @zzzLobster 👍