Skip to content

Commit

Permalink
extract
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzifu666 committed Sep 20, 2024
1 parent 7c96b04 commit adca102
Showing 1 changed file with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,7 @@ public String[] call(
Runtime.getRuntime().availableProcessors(),
ParameterUtils.parseCommaSeparatedKeyValues(properties));

int errorCount = 0;
int successCount = 0;

for (Migrator migrator : migrators) {
try {
migrator.executeMigrate();
migrator.renameTable(false);
successCount++;
} catch (Exception e) {
errorCount++;
LOG.error("Call migrate_database error:" + e.getMessage());
}
}
String retStr =
String.format(
"migrate database is finished, success cnt: %s , failed cnt: %s",
String.valueOf(successCount), String.valueOf(errorCount));

String retStr = handleMigrators(migrators);
return new String[] {retStr};
}

Expand All @@ -95,6 +78,11 @@ public String[] call(
p,
ParameterUtils.parseCommaSeparatedKeyValues(properties));

String retStr = handleMigrators(migrators);
return new String[] {retStr};
}

public String handleMigrators(List<Migrator> migrators) {
int errorCount = 0;
int successCount = 0;

Expand All @@ -112,7 +100,6 @@ public String[] call(
String.format(
"migrate database is finished, success cnt: %s , failed cnt: %s",
String.valueOf(successCount), String.valueOf(errorCount));

return new String[] {retStr};
return retStr;
}
}

0 comments on commit adca102

Please sign in to comment.