vishesh92 commented on code in PR #14490:
URL: https://github.com/apache/cloudstack/pull/14490#discussion_r4374061354
##########
engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql:
##########
@@ -239,3 +239,12 @@ CREATE TABLE IF NOT EXISTS
`cloud`.`instance_boot_group_details` (
PRIMARY KEY (`id`),
CONSTRAINT `fk_instance_boot_group_details__group_id` FOREIGN KEY
(`boot_group_id`) REFERENCES `instance_boot_group` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--- Add existing cross zone templates to the missing edge zones
+INSERT INTO cloud.template_zone_ref (zone_id, template_id, created,
last_updated)
+SELECT dc.id, vt.id, NOW(), NOW()
+FROM cloud.data_center dc
+JOIN cloud.vm_template vt ON vt.cross_zones = 1 AND vt.removed IS NULL
+WHERE dc.type = 'Edge' AND dc.removed IS NULL
+ AND NOT EXISTS (SELECT 1 FROM cloud.template_zone_ref tzr
+ WHERE tzr.zone_id = dc.id AND tzr.template_id = vt.id AND
tzr.removed IS NULL);
Review Comment:
This is fine as-is. template_zone_ref already has indexes on zone_id and
template_id, so each NOT EXISTS probe is an index lookup, and MySQL 8 executes
NOT EXISTS as an anti-join, which is effectively the same plan as LEFT JOIN …
IS NULL. The row count is edge zones × cross-zone templates and the migration
runs once, so I'd keep the NOT EXISTS form. It also keeps the removed IS NULL
condition clearly scoped to the subquery.
--
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]