Fix SQL query for uuid wrong format (#6654)

Fixes: #6652
This commit is contained in:
Nicolas Vazquez 2022-08-19 09:57:11 -03:00 committed by GitHub
parent 010b47f82e
commit 1fd1f0626a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -61,7 +61,7 @@ public class Upgrade41610to41700 implements DbUpgrade, DbUpgradeSystemVmTemplate
@Override
public void performDataMigration(Connection conn) {
fixWrongPoolUuid(conn);
fixWrongDatastoreClusterPoolUuid(conn);
}
@Override
@ -90,10 +90,11 @@ public class Upgrade41610to41700 implements DbUpgrade, DbUpgradeSystemVmTemplate
}
}
public void fixWrongPoolUuid(Connection conn) {
LOG.debug("Replacement of faulty pool uuids");
public void fixWrongDatastoreClusterPoolUuid(Connection conn) {
LOG.debug("Replacement of faulty pool uuids on datastorecluster");
try (PreparedStatement pstmt = conn.prepareStatement("SELECT id,uuid FROM storage_pool "
+ "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL;"); ResultSet rs = pstmt.executeQuery()) {
+ "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL "
+ "AND pool_type = 'DatastoreCluster';"); ResultSet rs = pstmt.executeQuery()) {
PreparedStatement updateStmt = conn.prepareStatement("update storage_pool set uuid = ? where id = ?");
while (rs.next()) {
UUID poolUuid = new UUID(