-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add support for multiple init scripts #2578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CREATE TABLE foo ( | ||
| bar VARCHAR(255) | ||
| ); | ||
|
|
||
| INSERT INTO foo (bar) VALUES ('hello world 2'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ public abstract class JdbcDatabaseContainer<SELF extends JdbcDatabaseContainer<S | |
|
|
||
| private static final Object DRIVER_LOAD_MUTEX = new Object(); | ||
| private Driver driver; | ||
| private String initScriptPath; | ||
| private String[] initScriptPaths; | ||
| protected Map<String, String> parameters = new HashMap<>(); | ||
|
|
||
| private int startupTimeoutSeconds = 120; | ||
|
|
@@ -108,7 +108,11 @@ public SELF withConnectTimeoutSeconds(int connectTimeoutSeconds) { | |
| } | ||
|
|
||
| public SELF withInitScript(String initScriptPath) { | ||
| this.initScriptPath = initScriptPath; | ||
| return withMultiInitScript(initScriptPath); | ||
| } | ||
|
|
||
| public SELF withMultiInitScript(String... initScriptPaths) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought but... If the parameters were
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same thought, but assumed the purpose was to keep the API visually and functionally the same. Now that you raise it up, it is a good question. The previous iteration was a lot simpler and less complicated. |
||
| this.initScriptPaths = initScriptPaths; | ||
| return self(); | ||
| } | ||
|
|
||
|
|
@@ -236,8 +240,8 @@ protected void optionallyMapResourceParameterAsVolume(@NotNull String paramName, | |
| * Load init script content and apply it to the database if initScriptPath is set | ||
| */ | ||
| protected void runInitScriptIfRequired() { | ||
| if (initScriptPath != null) { | ||
| ScriptUtils.runInitScript(getDatabaseDelegate(), initScriptPath); | ||
| if (initScriptPaths != null) { | ||
| ScriptUtils.runMultiInitScript(getDatabaseDelegate(), initScriptPaths); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need such big changes to
ScriptUtilsfor this? It looks like this other PR has a simpler approach, and I can't see why that wouldn't work...