Testcontainers-java: Improve usability of SQL init scripts with multiple file support

Created on 7 Jan 2020  路  4Comments  路  Source: testcontainers/testcontainers-java

Context

Issue originally raised on stackoverflow as a question.

It would be useful to be able to initialize a database with multiple startup scripts. In most projects that I've worked on, there are multiple onboarding scripts (database, schema, data, test-data etc). As such, when provisioning a new database using testcontainers for an integration test, it'd be helpful to be able to execute all of these scripts on startup without needing to merge them into a single script.

Suggestion

An additional API in JdbcDatabaseContainer

/**
  * Execute each script in the order of which they're provided
  */
public SELF withInitScript(String... initScriptPaths) {
    // ...
}

An additional consideration for this API might be the result of 2127

stale

All 4 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

Please consider reopening this issue. It should be possible to execute multiple init scripts.
My use-case: first script contains definitions of tables (DDL) and another script that is full of testdata.

@bjmi unless somebody wants to work on a PR to support it, keeping an issue open makes little sense. Would you like to work on such PR?

Also, have you considered using Flyway or Spring Boot's built-in support for data/schema SQL files?

Was this page helpful?
0 / 5 - 0 ratings