Copy over uninstalled servers during db move

This is to preserve playtime of players who played on those servers

Affects issues:
- Fixed #2050
This commit is contained in:
Risto Lahtela 2021-09-10 18:33:41 +03:00
parent bb20dff61c
commit 8ab1f075e8
2 changed files with 26 additions and 0 deletions

View File

@ -44,6 +44,31 @@ public class ServerQueries {
/* Static method class */
}
public static Query<Collection<Server>> fetchUninstalledServerInformation() {
String sql = SELECT + '*' + FROM + ServerTable.TABLE_NAME + WHERE + ServerTable.INSTALLED + "=?";
return new QueryStatement<Collection<Server>>(sql, 100) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setBoolean(1, false);
}
@Override
public Collection<Server> processResults(ResultSet set) throws SQLException {
Collection<Server> servers = new HashSet<>();
while (set.next()) {
servers.add(new Server(
set.getInt(ServerTable.SERVER_ID),
ServerUUID.fromString(set.getString(ServerTable.SERVER_UUID)),
set.getString(ServerTable.NAME),
set.getString(ServerTable.WEB_ADDRESS),
set.getBoolean(ServerTable.PROXY)
));
}
return servers;
}
};
}
/**
* Query database for all Plan server information.
*

View File

@ -84,6 +84,7 @@ public class BackupCopyTransaction extends RemoveEverythingTransaction {
}
private void copyPlanServerInformation() {
copy(LargeStoreQueries::storeAllPlanServerInformation, ServerQueries.fetchUninstalledServerInformation());
copy(LargeStoreQueries::storeAllPlanServerInformation, ServerQueries.fetchPlanServerInformationCollection());
}