Skip to content

Commit 79290bd

Browse files
authored
usage: use existing cloud_usage index procedures to widen the key
Use the pre-existing cloud_usage procedures instead of the two added in this PR. schema-41600to41610.sql:72 created this same key with IDEMPOTENT_ADD_UNIQUE_INDEX: CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`( 'cloud_usage.usage_volume', 'id', '(volume_id ASC, created ASC)'); so widening it the same way keeps the table's schema history consistent. Note the two procedures take their arguments in opposite orders: IDEMPOTENT_DROP_INDEX is (index_name, table_name), while IDEMPOTENT_ADD_UNIQUE_INDEX is (table_name, index_name, definition).
1 parent e5dd472 commit 79290bd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule', 'isolated', 'TINYI
646646

647647
UPDATE `cloud`.`configuration` SET `value`=CONCAT(`value`, ', backupValidationCommandTimeout, backupValidationScreenshotWait, backupValidationBootTimeout')
648648
WHERE `name`='user.vm.readonly.details' AND `value` IS NOT NULL;
649+
649650
-- Widen the unique key on cloud_usage.usage_volume to include vm_id, so the two volume
650651
-- usage records introduced in 4.22.1 (cumulative and per-VM) can coexist. See #13399.
651-
CALL `cloud_usage`.`IDEMPOTENT_DROP_UNIQUE_KEY`('cloud_usage.usage_volume', 'id');
652-
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud_usage.usage_volume', 'id', '(`volume_id`, `created`, `vm_id`)');
652+
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id', 'cloud_usage.usage_volume');
653+
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_volume', 'id', '(volume_id ASC, created ASC, vm_id ASC)');

0 commit comments

Comments
 (0)