This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.19 by this push:
     new a8cb7abca36 Add new column `last_id` to the table volumes (#9759)
a8cb7abca36 is described below

commit a8cb7abca36f9adb50ac49108e1b107840035c02
Author: Felipe <[email protected]>
AuthorDate: Thu Nov 28 13:51:53 2024 -0300

    Add new column `last_id` to the table volumes (#9759)
    
    Co-authored-by: João Jandre <[email protected]>
---
 engine/schema/src/main/java/com/cloud/storage/VolumeVO.java   | 11 +++++++++++
 .../src/main/resources/META-INF/db/schema-41900to41910.sql    |  3 +++
 .../storage/motion/StorageSystemDataMotionStrategy.java       |  2 ++
 .../apache/cloudstack/storage/volume/VolumeServiceImpl.java   |  1 +
 4 files changed, 17 insertions(+)

diff --git a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java 
b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java
index 0bd71ea6d86..5ccbf746b7e 100644
--- a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java
+++ b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java
@@ -48,6 +48,9 @@ public class VolumeVO implements Volume {
     @Column(name = "id")
     long id;
 
+    @Column(name = "last_id")
+    private long lastId;
+
     @Column(name = "name")
     String name;
 
@@ -677,4 +680,12 @@ public class VolumeVO implements Volume {
     public String getEncryptFormat() { return encryptFormat; }
 
     public void setEncryptFormat(String encryptFormat) { this.encryptFormat = 
encryptFormat; }
+
+    public long getLastId() {
+        return lastId;
+    }
+
+    public void setLastId(long lastId) {
+        this.lastId = lastId;
+    }
 }
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql
index 0cb10f4a0ef..028c3f619db 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql
@@ -70,3 +70,6 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user_data', 
'removed', 'datetime COM
 UPDATE `cloud`.`configuration` SET
     `options` = 
'FirstFitRouting,RandomAllocator,TestingAllocator,FirstFitAllocator,RecreateHostAllocator'
 WHERE `name` = 'host.allocators.order';
+
+-- Add last_id to the volumes table
+CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('volumes','last_id', 'bigint(20) unsigned 
DEFAULT NULL');
diff --git 
a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
 
b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
index 0efc0b7dc1c..398ce41db4a 100644
--- 
a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
+++ 
b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
@@ -2292,6 +2292,8 @@ public class StorageSystemDataMotionStrategy implements 
DataMotionStrategy {
             if (success) {
                 VolumeVO volumeVO = 
_volumeDao.findById(destVolumeInfo.getId());
                 volumeVO.setFormat(ImageFormat.QCOW2);
+                volumeVO.setLastId(srcVolumeInfo.getId());
+
                 _volumeDao.update(volumeVO.getId(), volumeVO);
 
                 
_volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed,
 null, srcVolumeInfo, destVolumeInfo, false);
diff --git 
a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
 
b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 63726b40093..65fe25fe3cf 100644
--- 
a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ 
b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -1720,6 +1720,7 @@ public class VolumeServiceImpl implements VolumeService {
             newVol.setPassphraseId(volume.getPassphraseId());
             newVol.setEncryptFormat(volume.getEncryptFormat());
         }
+        newVol.setLastId(volume.getId());
         return volDao.persist(newVol);
     }
 

Reply via email to