Skip to content

Commit

Permalink
fix: Database naming issue
Browse files Browse the repository at this point in the history
- fixes #15
- fixes #14
- fixes #13

Signed-off-by: Andreas Reichel <[email protected]>
  • Loading branch information
manticore-projects committed Mar 9, 2024
1 parent 7db6e9e commit 8262d66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/com/manticore/h2/H2MigrationTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public void run() {
if (versionFrom != null && versionFrom.length() > 1) {
app.migrate(versionFrom, versionTo, databaseFileName, user, password,
scriptFileName,
compression, upgradeOptions, overwrite, force, null);
compression, upgradeOptions, overwrite, force, "");
} else {
app.migrateAuto(versionTo, databaseFileName, user, password, scriptFileName,
compression,
Expand Down Expand Up @@ -660,7 +660,7 @@ public ScriptResult writeScript(DriverRecord driverRecord, String databaseFileNa
properties.setProperty("password", password);
Driver driver = loadDriver(driverRecord);
try (Connection connection = driver.connect(
"jdbc:h2:" + databaseFileName + ";ACCESS_MODE_DATA=r" + connectionParameters,
"jdbc:h2:" + databaseFileName + ";ACCESS_MODE_DATA=r" + Objects.requireNonNull(connectionParameters),
properties)) {
List<String> commands = executeHooks(connection, HookStage.IMPORT);
executeHooks(connection, HookStage.EXPORT);
Expand Down Expand Up @@ -835,7 +835,7 @@ public ScriptResult migrate(String versionFrom, String versionTo, String databas

scriptResult =
writeScript(driverRecordFrom, modifiedDatabaseFileName, user, password,
modifiedScriptFileName, modifiedCompression, connectionParameters);
modifiedScriptFileName, modifiedCompression, Objects.requireNonNull(connectionParameters));

modifiedScriptFileName = scriptResult.scriptFileName;
commands.addAll(scriptResult.commands);
Expand Down Expand Up @@ -894,16 +894,16 @@ public ScriptResult migrate(String versionFrom, String versionTo, String databas
}

String options =
modifiedCompression != null && modifiedCompression.length() > 0
modifiedCompression != null && !modifiedCompression.isEmpty()
? modifiedCompression + " " + upgradeOptions
: upgradeOptions;

if (success) {
try {
scriptResult = createFromScript(driverRecordTo, databaseFileName, user, password,
modifiedScriptFileName, options, commands, force, connectionParameters);
modifiedDatabaseFileName = databaseFileName + "." + driverRecordTo.patchId
+ (!driverRecordTo.buildId.isEmpty() ? ("-" + driverRecordTo.buildId) : "");
scriptResult = createFromScript(driverRecordTo, modifiedDatabaseFileName, user, password,
modifiedScriptFileName, options, commands, force, Objects.requireNonNull(connectionParameters));
modifiedDatabaseFileName = modifiedDatabaseFileName + "." + driverRecordTo.patchId
+ (!driverRecordTo.buildId.isEmpty() ? ("-" + driverRecordTo.buildId) : "") + ".mv.db";


LOGGER.info("Created new " + driverRecordTo + " database: "
Expand Down Expand Up @@ -1024,14 +1024,14 @@ public boolean accept(File dir, String name) {
}

String options =
compression != null && compression.length() > 0
compression != null && !compression.isEmpty()
? compression + " " + upgradeOptions
: upgradeOptions;
if (success) {
try {
ScriptResult scriptResult =
createFromScript(driverRecordTo, databaseName, user, password,
modifiedScriptFileName, options, commands, force, null);
modifiedScriptFileName, options, commands, force, "");

databaseName = scriptResult.scriptFileName;
LOGGER.info("Created new " + driverRecordTo + " database: "
Expand Down
Binary file modified src/main/resources/drivers/h2-2.2.229-SNAPSHOT.bin
Binary file not shown.

0 comments on commit 8262d66

Please sign in to comment.