harikrishna-patnala commented on a change in pull request #5008:
URL: https://github.com/apache/cloudstack/pull/5008#discussion_r684897193



##########
File path: engine/schema/src/main/resources/META-INF/db/schema-41510to41600.sql
##########
@@ -19,21 +19,293 @@
 -- Schema upgrade from 4.15.1.0 to 4.16.0.0
 --;
 
--- Adding dynamic scalable flag for service offering table
-ALTER TABLE `cloud`.`service_offering` ADD COLUMN `dynamic_scaling_enabled` 
tinyint(1) unsigned NOT NULL DEFAULT 1  COMMENT 'true(1) if VM needs to be 
dynamically scalable of cpu or memory';
-DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
-CREATE VIEW `cloud`.`service_offering_view` AS
+
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `uuid` varchar(40) UNIQUE;
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `name` varchar(255);
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `display_text` varchar(4096);
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `unique_name` varchar(32) 
COMMENT 'unique name for system offerings';
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `customized` tinyint(1) 
unsigned NOT NULL DEFAULT 0  COMMENT '0 implies not customized by default';
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `created` datetime COMMENT 
'date when service offering was created';
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `removed` datetime COMMENT 
'date when service offering was removed';
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `state` CHAR(40) NOT NULL 
DEFAULT 'Active' COMMENT 'state of service offering either Active or Inactive';
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `disk_offering_id` bigint 
unsigned;
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `system_use` tinyint(1) 
unsigned NOT NULL DEFAULT 0 COMMENT 'is this offering for system used only';
+ALTER TABLE `cloud`.`service_offering` ADD CONSTRAINT 
`fk_service_offering__disk_offering_id` FOREIGN KEY 
`fk_service_offering__disk_offering_id`(`disk_offering_id`) REFERENCES 
`disk_offering`(`id`) ON DELETE CASCADE;
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `disk_offering_strictness` 
tinyint(1) unsigned NOT NULL DEFAULT 0  COMMENT 'strict binding with disk 
offering or not';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `disk_size_strictness` 
tinyint(1) unsigned NOT NULL DEFAULT 0  COMMENT 'To allow or disallow the 
resize operation on the disks created from this offering';
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `compute_only` tinyint(1) 
unsigned NOT NULL DEFAULT 0  COMMENT 'when set to 1, disk offering has one to 
one binding with service offering';
+ALTER TABLE `cloud`.`disk_offering` DROP COLUMN `type`;
+
+ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `disk_offering_id`;
+
+UPDATE `cloud`.`service_offering` so, `cloud`.`disk_offering` do SET so.`name` 
= do.`name`, so.`display_text` = do.`display_text` WHERE so.`id` = do.`id`;
+
+DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
+CREATE
+VIEW `user_vm_view` AS
     SELECT
-        `service_offering`.`id` AS `id`,
+        `vm_instance`.`id` AS `id`,
+        `vm_instance`.`name` AS `name`,
+        `user_vm`.`display_name` AS `display_name`,
+        `user_vm`.`user_data` AS `user_data`,
+        `account`.`id` AS `account_id`,
+        `account`.`uuid` AS `account_uuid`,
+        `account`.`account_name` AS `account_name`,
+        `account`.`type` AS `account_type`,
+        `domain`.`id` AS `domain_id`,
+        `domain`.`uuid` AS `domain_uuid`,
+        `domain`.`name` AS `domain_name`,
+        `domain`.`path` AS `domain_path`,
+        `projects`.`id` AS `project_id`,
+        `projects`.`uuid` AS `project_uuid`,
+        `projects`.`name` AS `project_name`,
+        `instance_group`.`id` AS `instance_group_id`,
+        `instance_group`.`uuid` AS `instance_group_uuid`,
+        `instance_group`.`name` AS `instance_group_name`,
+        `vm_instance`.`uuid` AS `uuid`,
+        `vm_instance`.`user_id` AS `user_id`,
+        `vm_instance`.`last_host_id` AS `last_host_id`,
+        `vm_instance`.`vm_type` AS `type`,
+        `vm_instance`.`limit_cpu_use` AS `limit_cpu_use`,
+        `vm_instance`.`created` AS `created`,
+        `vm_instance`.`state` AS `state`,
+        `vm_instance`.`removed` AS `removed`,
+        `vm_instance`.`ha_enabled` AS `ha_enabled`,
+        `vm_instance`.`hypervisor_type` AS `hypervisor_type`,
+        `vm_instance`.`instance_name` AS `instance_name`,
+        `vm_instance`.`guest_os_id` AS `guest_os_id`,
+        `vm_instance`.`display_vm` AS `display_vm`,
+        `guest_os`.`uuid` AS `guest_os_uuid`,
+        `vm_instance`.`pod_id` AS `pod_id`,
+        `host_pod_ref`.`uuid` AS `pod_uuid`,
+        `vm_instance`.`private_ip_address` AS `private_ip_address`,
+        `vm_instance`.`private_mac_address` AS `private_mac_address`,
+        `vm_instance`.`vm_type` AS `vm_type`,
+        `data_center`.`id` AS `data_center_id`,
+        `data_center`.`uuid` AS `data_center_uuid`,
+        `data_center`.`name` AS `data_center_name`,
+        `data_center`.`is_security_group_enabled` AS `security_group_enabled`,
+        `data_center`.`networktype` AS `data_center_type`,
+        `host`.`id` AS `host_id`,
+        `host`.`uuid` AS `host_uuid`,
+        `host`.`name` AS `host_name`,
+        `vm_template`.`id` AS `template_id`,
+        `vm_template`.`uuid` AS `template_uuid`,
+        `vm_template`.`name` AS `template_name`,
+        `vm_template`.`display_text` AS `template_display_text`,
+        `vm_template`.`enable_password` AS `password_enabled`,
+        `iso`.`id` AS `iso_id`,
+        `iso`.`uuid` AS `iso_uuid`,
+        `iso`.`name` AS `iso_name`,
+        `iso`.`display_text` AS `iso_display_text`,
+        `service_offering`.`id` AS `service_offering_id`,
+        `service_offering`.`uuid` AS `service_offering_uuid`,
+        `disk_offering`.`uuid` AS `disk_offering_uuid`,
+        `disk_offering`.`id` AS `disk_offering_id`,
+        (CASE
+            WHEN ISNULL(`service_offering`.`cpu`) THEN `custom_cpu`.`value`
+            ELSE `service_offering`.`cpu`
+        END) AS `cpu`,
+        (CASE
+            WHEN ISNULL(`service_offering`.`speed`) THEN `custom_speed`.`value`
+            ELSE `service_offering`.`speed`
+        END) AS `speed`,
+        (CASE
+            WHEN ISNULL(`service_offering`.`ram_size`) THEN 
`custom_ram_size`.`value`
+            ELSE `service_offering`.`ram_size`
+        END) AS `ram_size`,
+        `backup_offering`.`uuid` AS `backup_offering_uuid`,
+        `backup_offering`.`id` AS `backup_offering_id`,
+        `service_offering`.`name` AS `service_offering_name`,
+        `disk_offering`.`name` AS `disk_offering_name`,
+        `backup_offering`.`name` AS `backup_offering_name`,
+        `storage_pool`.`id` AS `pool_id`,
+        `storage_pool`.`uuid` AS `pool_uuid`,
+        `storage_pool`.`pool_type` AS `pool_type`,
+        `volumes`.`id` AS `volume_id`,
+        `volumes`.`uuid` AS `volume_uuid`,
+        `volumes`.`device_id` AS `volume_device_id`,
+        `volumes`.`volume_type` AS `volume_type`,
+        `security_group`.`id` AS `security_group_id`,
+        `security_group`.`uuid` AS `security_group_uuid`,
+        `security_group`.`name` AS `security_group_name`,
+        `security_group`.`description` AS `security_group_description`,
+        `nics`.`id` AS `nic_id`,
+        `nics`.`uuid` AS `nic_uuid`,
+        `nics`.`network_id` AS `network_id`,
+        `nics`.`ip4_address` AS `ip_address`,
+        `nics`.`ip6_address` AS `ip6_address`,
+        `nics`.`ip6_gateway` AS `ip6_gateway`,
+        `nics`.`ip6_cidr` AS `ip6_cidr`,
+        `nics`.`default_nic` AS `is_default_nic`,
+        `nics`.`gateway` AS `gateway`,
+        `nics`.`netmask` AS `netmask`,
+        `nics`.`mac_address` AS `mac_address`,
+        `nics`.`broadcast_uri` AS `broadcast_uri`,
+        `nics`.`isolation_uri` AS `isolation_uri`,
+        `vpc`.`id` AS `vpc_id`,
+        `vpc`.`uuid` AS `vpc_uuid`,
+        `networks`.`uuid` AS `network_uuid`,
+        `networks`.`name` AS `network_name`,
+        `networks`.`traffic_type` AS `traffic_type`,
+        `networks`.`guest_type` AS `guest_type`,
+        `user_ip_address`.`id` AS `public_ip_id`,
+        `user_ip_address`.`uuid` AS `public_ip_uuid`,
+        `user_ip_address`.`public_ip_address` AS `public_ip_address`,
+        `ssh_keypairs`.`keypair_name` AS `keypair_name`,
+        `resource_tags`.`id` AS `tag_id`,
+        `resource_tags`.`uuid` AS `tag_uuid`,
+        `resource_tags`.`key` AS `tag_key`,
+        `resource_tags`.`value` AS `tag_value`,
+        `resource_tags`.`domain_id` AS `tag_domain_id`,
+        `domain`.`uuid` AS `tag_domain_uuid`,
+        `domain`.`name` AS `tag_domain_name`,
+        `resource_tags`.`account_id` AS `tag_account_id`,
+        `account`.`account_name` AS `tag_account_name`,
+        `resource_tags`.`resource_id` AS `tag_resource_id`,
+        `resource_tags`.`resource_uuid` AS `tag_resource_uuid`,
+        `resource_tags`.`resource_type` AS `tag_resource_type`,
+        `resource_tags`.`customer` AS `tag_customer`,
+        `async_job`.`id` AS `job_id`,
+        `async_job`.`uuid` AS `job_uuid`,
+        `async_job`.`job_status` AS `job_status`,
+        `async_job`.`account_id` AS `job_account_id`,
+        `affinity_group`.`id` AS `affinity_group_id`,
+        `affinity_group`.`uuid` AS `affinity_group_uuid`,
+        `affinity_group`.`name` AS `affinity_group_name`,
+        `affinity_group`.`description` AS `affinity_group_description`,
+        `vm_instance`.`dynamically_scalable` AS `dynamically_scalable`
+    FROM
+        (((((((((((((((((((((((((((((((((`user_vm`
+        JOIN `vm_instance` ON (((`vm_instance`.`id` = `user_vm`.`id`)
+            AND ISNULL(`vm_instance`.`removed`))))
+        JOIN `account` ON ((`vm_instance`.`account_id` = `account`.`id`)))
+        JOIN `domain` ON ((`vm_instance`.`domain_id` = `domain`.`id`)))
+        LEFT JOIN `guest_os` ON ((`vm_instance`.`guest_os_id` = 
`guest_os`.`id`)))
+        LEFT JOIN `host_pod_ref` ON ((`vm_instance`.`pod_id` = 
`host_pod_ref`.`id`)))
+        LEFT JOIN `projects` ON ((`projects`.`project_account_id` = 
`account`.`id`)))
+        LEFT JOIN `instance_group_vm_map` ON ((`vm_instance`.`id` = 
`instance_group_vm_map`.`instance_id`)))
+        LEFT JOIN `instance_group` ON ((`instance_group_vm_map`.`group_id` = 
`instance_group`.`id`)))
+        LEFT JOIN `data_center` ON ((`vm_instance`.`data_center_id` = 
`data_center`.`id`)))
+        LEFT JOIN `host` ON ((`vm_instance`.`host_id` = `host`.`id`)))
+        LEFT JOIN `vm_template` ON ((`vm_instance`.`vm_template_id` = 
`vm_template`.`id`)))
+        LEFT JOIN `vm_template` `iso` ON ((`iso`.`id` = `user_vm`.`iso_id`)))
+        LEFT JOIN `volumes` ON ((`vm_instance`.`id` = 
`volumes`.`instance_id`)))
+        LEFT JOIN `service_offering` ON ((`vm_instance`.`service_offering_id` 
= `service_offering`.`id`)))
+        LEFT JOIN `disk_offering` `svc_disk_offering` ON 
((`volumes`.`disk_offering_id` = `svc_disk_offering`.`id`)))
+        LEFT JOIN `disk_offering` ON ((`volumes`.`disk_offering_id` = 
`disk_offering`.`id`)))
+        LEFT JOIN `backup_offering` ON ((`vm_instance`.`backup_offering_id` = 
`backup_offering`.`id`)))
+        LEFT JOIN `storage_pool` ON ((`volumes`.`pool_id` = 
`storage_pool`.`id`)))
+        LEFT JOIN `security_group_vm_map` ON ((`vm_instance`.`id` = 
`security_group_vm_map`.`instance_id`)))
+        LEFT JOIN `security_group` ON 
((`security_group_vm_map`.`security_group_id` = `security_group`.`id`)))
+        LEFT JOIN `nics` ON (((`vm_instance`.`id` = `nics`.`instance_id`)
+            AND ISNULL(`nics`.`removed`))))
+        LEFT JOIN `networks` ON ((`nics`.`network_id` = `networks`.`id`)))
+        LEFT JOIN `vpc` ON (((`networks`.`vpc_id` = `vpc`.`id`)
+            AND ISNULL(`vpc`.`removed`))))
+        LEFT JOIN `user_ip_address` ON ((`user_ip_address`.`vm_id` = 
`vm_instance`.`id`)))
+        LEFT JOIN `user_vm_details` `ssh_details` ON (((`ssh_details`.`vm_id` 
= `vm_instance`.`id`)
+            AND (`ssh_details`.`name` = 'SSH.PublicKey'))))
+        LEFT JOIN `ssh_keypairs` ON (((`ssh_keypairs`.`public_key` = 
`ssh_details`.`value`)
+            AND (`ssh_keypairs`.`account_id` = `account`.`id`))))
+        LEFT JOIN `resource_tags` ON (((`resource_tags`.`resource_id` = 
`vm_instance`.`id`)
+            AND (`resource_tags`.`resource_type` = 'UserVm'))))
+        LEFT JOIN `async_job` ON (((`async_job`.`instance_id` = 
`vm_instance`.`id`)
+            AND (`async_job`.`instance_type` = 'VirtualMachine')
+            AND (`async_job`.`job_status` = 0))))
+        LEFT JOIN `affinity_group_vm_map` ON ((`vm_instance`.`id` = 
`affinity_group_vm_map`.`instance_id`)))
+        LEFT JOIN `affinity_group` ON 
((`affinity_group_vm_map`.`affinity_group_id` = `affinity_group`.`id`)))
+        LEFT JOIN `user_vm_details` `custom_cpu` ON (((`custom_cpu`.`vm_id` = 
`vm_instance`.`id`)
+            AND (`custom_cpu`.`name` = 'CpuNumber'))))
+        LEFT JOIN `user_vm_details` `custom_speed` ON 
(((`custom_speed`.`vm_id` = `vm_instance`.`id`)
+            AND (`custom_speed`.`name` = 'CpuSpeed'))))
+        LEFT JOIN `user_vm_details` `custom_ram_size` ON 
(((`custom_ram_size`.`vm_id` = `vm_instance`.`id`)
+            AND (`custom_ram_size`.`name` = 'memory'))));
+
+DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
+CREATE VIEW `cloud`.`disk_offering_view` AS
+    SELECT
+        `disk_offering`.`id` AS `id`,
         `disk_offering`.`uuid` AS `uuid`,
         `disk_offering`.`name` AS `name`,
         `disk_offering`.`display_text` AS `display_text`,
         `disk_offering`.`provisioning_type` AS `provisioning_type`,
+        `disk_offering`.`disk_size` AS `disk_size`,
+        `disk_offering`.`min_iops` AS `min_iops`,
+        `disk_offering`.`max_iops` AS `max_iops`,
         `disk_offering`.`created` AS `created`,
         `disk_offering`.`tags` AS `tags`,
+        `disk_offering`.`customized` AS `customized`,
+        `disk_offering`.`customized_iops` AS `customized_iops`,
         `disk_offering`.`removed` AS `removed`,
         `disk_offering`.`use_local_storage` AS `use_local_storage`,
         `disk_offering`.`system_use` AS `system_use`,
+        `disk_offering`.`hv_ss_reserve` AS `hv_ss_reserve`,
+        `disk_offering`.`bytes_read_rate` AS `bytes_read_rate`,
+        `disk_offering`.`bytes_read_rate_max` AS `bytes_read_rate_max`,
+        `disk_offering`.`bytes_read_rate_max_length` AS 
`bytes_read_rate_max_length`,
+        `disk_offering`.`bytes_write_rate` AS `bytes_write_rate`,
+        `disk_offering`.`bytes_write_rate_max` AS `bytes_write_rate_max`,
+        `disk_offering`.`bytes_write_rate_max_length` AS 
`bytes_write_rate_max_length`,
+        `disk_offering`.`iops_read_rate` AS `iops_read_rate`,
+        `disk_offering`.`iops_read_rate_max` AS `iops_read_rate_max`,
+        `disk_offering`.`iops_read_rate_max_length` AS 
`iops_read_rate_max_length`,
+        `disk_offering`.`iops_write_rate` AS `iops_write_rate`,
+        `disk_offering`.`iops_write_rate_max` AS `iops_write_rate_max`,
+        `disk_offering`.`iops_write_rate_max_length` AS 
`iops_write_rate_max_length`,
+        `disk_offering`.`cache_mode` AS `cache_mode`,
+        `disk_offering`.`sort_key` AS `sort_key`,
+        `disk_offering`.`compute_only` AS `compute_only`,
+        `disk_offering`.`display_offering` AS `display_offering`,
+        `disk_offering`.`state` AS `state`,
+        `disk_offering`.`disk_size_strictness` AS `disk_size_strictness`,
+        `vsphere_storage_policy`.`value` AS `vsphere_storage_policy`,
+        GROUP_CONCAT(DISTINCT(domain.id)) AS domain_id,
+        GROUP_CONCAT(DISTINCT(domain.uuid)) AS domain_uuid,
+        GROUP_CONCAT(DISTINCT(domain.name)) AS domain_name,
+        GROUP_CONCAT(DISTINCT(domain.path)) AS domain_path,
+        GROUP_CONCAT(DISTINCT(zone.id)) AS zone_id,
+        GROUP_CONCAT(DISTINCT(zone.uuid)) AS zone_uuid,
+        GROUP_CONCAT(DISTINCT(zone.name)) AS zone_name
+    FROM
+        `cloud`.`disk_offering`
+            LEFT JOIN
+        `cloud`.`disk_offering_details` AS `domain_details` ON 
`domain_details`.`offering_id` = `disk_offering`.`id` AND 
`domain_details`.`name`='domainid'
+            LEFT JOIN
+        `cloud`.`domain` AS `domain` ON FIND_IN_SET(`domain`.`id`, 
`domain_details`.`value`)
+            LEFT JOIN
+        `cloud`.`disk_offering_details` AS `zone_details` ON 
`zone_details`.`offering_id` = `disk_offering`.`id` AND 
`zone_details`.`name`='zoneid'
+            LEFT JOIN
+        `cloud`.`data_center` AS `zone` ON FIND_IN_SET(`zone`.`id`, 
`zone_details`.`value`)
+                       LEFT JOIN
+               `cloud`.`disk_offering_details` AS `vsphere_storage_policy` ON 
`vsphere_storage_policy`.`offering_id` = `disk_offering`.`id`
+                               AND `vsphere_storage_policy`.`name` = 
'storagepolicy'
+    WHERE
+        `disk_offering`.`state`='Active'
+    GROUP BY
+        `disk_offering`.`id`;
+
+-- Adding dynamic scalable flag for service offering table
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `dynamic_scaling_enabled` 
tinyint(1) unsigned NOT NULL DEFAULT 1  COMMENT 'true(1) if VM needs to be 
dynamically scalable of cpu or memory';

Review comment:
       This is part of another PR#4643
   -- Adding dynamic scalable flag for service offering table
   ALTER TABLE `cloud`.`service_offering` ADD COLUMN `dynamic_scaling_enabled` 
tinyint(1) unsigned NOT NULL DEFAULT 1  COMMENT 'true(1) if VM needs to be 
dynamically scalable of cpu or memory';
   
   I've just changed the place of the existing ALTER command, not sure why the 
delete change is missing.




-- 
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