DK101010 commented on a change in pull request #5382:
URL: https://github.com/apache/cloudstack/pull/5382#discussion_r719267970



##########
File path: 
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41520to41600.java
##########
@@ -65,6 +68,31 @@ public boolean supportsRollingUpgrade() {
     @Override
     public void performDataMigration(Connection conn) {
         generateUuidForExistingSshKeyPairs(conn);
+        fixWrongPoolUuid(conn);
+    }
+
+    public void fixWrongPoolUuid(Connection conn) {
+        LOG.debug("Replacement of faulty pool uuids");
+        try (PreparedStatement pstmt = conn.prepareStatement("SELECT id,uuid 
FROM storage_pool "
+                + "WHERE removed IS NULL;"); ResultSet rs = 
pstmt.executeQuery()) {
+            PreparedStatement updateStmt = conn.prepareStatement("update 
storage_pool set uuid = ? where id = ?");
+            while (rs.next()) {
+                if (!rs.getString(2).contains("-")) {

Review comment:
       Hi @DaanHoogland, hmm not quite sure what do you mean. I'm updating only 
uuids with the wrong format or do you want to reduce the result set of this 
query with a regular expression 
   `SELECT id,uuid FROM storage_pool  WHERE removed IS NULL;`
   If yes, I'm not really a fan of regular expressions in sql queries and I try 
to prevent this if it not absolutely necessary. 
   The result set should be not so big, therefore this solution. But I can 
change this if it requested.
   
   I'm check out the storage pool table and in my opinion the conditions are 
right.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to