mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-02-15 01:41:58 +01:00
Added progress to migration and made error messages prettier (#67)
This commit is contained in:
parent
9368dfea75
commit
7199acb8ef
@ -80,7 +80,8 @@ public class Migrations {
|
|||||||
try {
|
try {
|
||||||
accounts.executeRawNoArgs("INSERT INTO `accounts` (name, shortName, uuid) SELECT name, shortName, uuid FROM `accounts-old`");
|
accounts.executeRawNoArgs("INSERT INTO `accounts` (name, shortName, uuid) SELECT name, shortName, uuid FROM `accounts-old`");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ChestShop.getBukkitLogger().log(Level.WARNING, "Fast accounts migration failed! (" + e.getMessage() + "). Starting slow migration...");
|
ChestShop.getBukkitLogger().log(Level.WARNING, "Fast accounts migration failed!\n" + e + "\nCause: " + e.getCause());
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "Starting slow migration...");
|
||||||
accounts.executeRawNoArgs("DELETE FROM `accounts`");
|
accounts.executeRawNoArgs("DELETE FROM `accounts`");
|
||||||
|
|
||||||
GenericRawResults<String[]> results = accounts.queryRaw("SELECT name, shortName, uuid FROM `accounts-old`");
|
GenericRawResults<String[]> results = accounts.queryRaw("SELECT name, shortName, uuid FROM `accounts-old`");
|
||||||
@ -88,6 +89,7 @@ public class Migrations {
|
|||||||
int success = 0;
|
int success = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
CloseableIterator<String[]> resultIterator = results.closeableIterator();
|
CloseableIterator<String[]> resultIterator = results.closeableIterator();
|
||||||
|
long lastInfo = System.currentTimeMillis();
|
||||||
while (resultIterator.hasNext()) {
|
while (resultIterator.hasNext()) {
|
||||||
String[] strings = resultIterator.next();
|
String[] strings = resultIterator.next();
|
||||||
Account account = new Account(strings[0], UUID.fromString(strings[2]));
|
Account account = new Account(strings[0], UUID.fromString(strings[2]));
|
||||||
@ -98,7 +100,12 @@ public class Migrations {
|
|||||||
success++;
|
success++;
|
||||||
} catch (SQLException x) {
|
} catch (SQLException x) {
|
||||||
error++;
|
error++;
|
||||||
ChestShop.getBukkitLogger().log(Level.SEVERE, "Could not load account " + account.getName() + "/" + account.getShortName() + "/" + account.getUuid() + " to new database format", x);
|
ChestShop.getBukkitLogger().log(Level.SEVERE, "Could not migrate account " + account.getName() + "/" + account.getShortName() + "/" + account.getUuid() + " to new database format:\n" + x + "\nCause: " + x.getCause());
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "If the cause is a constraint violation then this is nothing to worry about!");
|
||||||
|
}
|
||||||
|
if (lastInfo + 60 * 1000 < System.currentTimeMillis()) {
|
||||||
|
ChestShop.getBukkitLogger().log(Level.INFO, "Slow migration in progress... " + (System.currentTimeMillis() - start) / 1000.0 + "s elapsed - " + success + " migrated - " + error + " errors");
|
||||||
|
lastInfo = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results.close();
|
results.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user