Skip to content

Commit 3109c59

Browse files
authored
CLOUDSTACK-10285: Fix db upgrade failure for 4.10.0.0 users (#2452)
4.10.0.0 users when upgrade to 4.11.0.0 may face db related discrepancies due to some PRs that got merged without moving their sql changes to 4.10->4.11 upgrade path. The 4.10.0.0 users can run those missing sql statements manually and then upgrade to 4.11.0.0, since a workaround like this is possible this ticket is not marked a blocker. In 4.11.1.0+, we'll move those changes from 4.9.3.0->4.10.0.0 upgrade path to 4.10.0.0->4.11.0.0 upgrade path. Ideally we should not be doing this, but this will fix issues for a future 4.10.0.0 user who may want to upgrade to 4.11.1.0 or 4.12.0.0+. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent dee5bb5 commit 3109c59

4 files changed

Lines changed: 67 additions & 69 deletions

File tree

engine/schema/resources/META-INF/db/schema-41000to41100-cleanup.sql

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,49 @@
2121

2222
DELETE FROM `cloud`.`configuration` WHERE name='snapshot.backup.rightafter';
2323
-- CLOUDSTACK-9914: Alter quota_tariff to support currency values up to 5 decimal places
24-
ALTER TABLE `cloud_usage`.`quota_tariff` MODIFY `currency_value` DECIMAL(15,5) not null
24+
ALTER TABLE `cloud_usage`.`quota_tariff` MODIFY `currency_value` DECIMAL(15,5) not null;
25+
26+
DROP VIEW IF EXISTS `cloud`.`user_view`;
27+
CREATE VIEW `cloud`.`user_view` AS
28+
select
29+
user.id,
30+
user.uuid,
31+
user.username,
32+
user.password,
33+
user.firstname,
34+
user.lastname,
35+
user.email,
36+
user.state,
37+
user.api_key,
38+
user.secret_key,
39+
user.created,
40+
user.removed,
41+
user.timezone,
42+
user.registration_token,
43+
user.is_registered,
44+
user.incorrect_login_attempts,
45+
user.source,
46+
user.default,
47+
account.id account_id,
48+
account.uuid account_uuid,
49+
account.account_name account_name,
50+
account.type account_type,
51+
account.role_id account_role_id,
52+
domain.id domain_id,
53+
domain.uuid domain_uuid,
54+
domain.name domain_name,
55+
domain.path domain_path,
56+
async_job.id job_id,
57+
async_job.uuid job_uuid,
58+
async_job.job_status job_status,
59+
async_job.account_id job_account_id
60+
from
61+
`cloud`.`user`
62+
inner join
63+
`cloud`.`account` ON user.account_id = account.id
64+
inner join
65+
`cloud`.`domain` ON account.domain_id = domain.id
66+
left join
67+
`cloud`.`async_job` ON async_job.instance_id = user.id
68+
and async_job.instance_type = 'User'
69+
and async_job.job_status = 0;

engine/schema/resources/META-INF/db/schema-41000to41100.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,24 @@ ALTER TABLE cloud.ldap_trust_map ADD COLUMN account_id BIGINT(20) DEFAULT 0;
546546
ALTER TABLE cloud.ldap_trust_map DROP FOREIGN KEY fk_ldap_trust_map__domain_id;
547547
DROP INDEX uk_ldap_trust_map__domain_id ON cloud.ldap_trust_map;
548548
CREATE UNIQUE INDEX uk_ldap_trust_map__bind_location ON ldap_trust_map (domain_id, account_id);
549+
550+
CREATE TABLE IF NOT EXISTS `cloud`.`netscaler_servicepackages` (
551+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
552+
`uuid` varchar(255) UNIQUE,
553+
`name` varchar(255) UNIQUE COMMENT 'name of the service package',
554+
`description` varchar(255) COMMENT 'description of the service package',
555+
PRIMARY KEY (`id`)
556+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
557+
558+
CREATE TABLE IF NOT EXISTS `cloud`.`external_netscaler_controlcenter` (
559+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
560+
`uuid` varchar(255) UNIQUE,
561+
`username` varchar(255) COMMENT 'username of the NCC',
562+
`password` varchar(255) COMMENT 'password of NCC',
563+
`ncc_ip` varchar(255) COMMENT 'IP of NCC Manager',
564+
`num_retries` bigint unsigned NOT NULL default 2 COMMENT 'Number of retries in ncc for command failure',
565+
PRIMARY KEY (`id`)
566+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
567+
568+
ALTER TABLE `cloud`.`sslcerts` ADD COLUMN `name` varchar(255) NULL default NULL COMMENT 'Name of the Certificate';
569+
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `service_package_id` varchar(255) NULL default NULL COMMENT 'Netscaler ControlCenter Service Package';

engine/schema/resources/META-INF/db/schema-4930to41000-cleanup.sql

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,3 @@
2222
DELETE FROM `cloud`.`configuration` WHERE name='consoleproxy.loadscan.interval';
2323

2424
DELETE FROM `cloud`.`host_details` where name = 'vmName' and value in (select name from `cloud`.`vm_instance` where state = 'Expunging' and hypervisor_type ='BareMetal');
25-
26-
DROP VIEW IF EXISTS `cloud`.`user_view`;
27-
CREATE VIEW `cloud`.`user_view` AS
28-
select
29-
user.id,
30-
user.uuid,
31-
user.username,
32-
user.password,
33-
user.firstname,
34-
user.lastname,
35-
user.email,
36-
user.state,
37-
user.api_key,
38-
user.secret_key,
39-
user.created,
40-
user.removed,
41-
user.timezone,
42-
user.registration_token,
43-
user.is_registered,
44-
user.incorrect_login_attempts,
45-
user.source,
46-
user.default,
47-
account.id account_id,
48-
account.uuid account_uuid,
49-
account.account_name account_name,
50-
account.type account_type,
51-
account.role_id account_role_id,
52-
domain.id domain_id,
53-
domain.uuid domain_uuid,
54-
domain.name domain_name,
55-
domain.path domain_path,
56-
async_job.id job_id,
57-
async_job.uuid job_uuid,
58-
async_job.job_status job_status,
59-
async_job.account_id job_account_id
60-
from
61-
`cloud`.`user`
62-
inner join
63-
`cloud`.`account` ON user.account_id = account.id
64-
inner join
65-
`cloud`.`domain` ON account.domain_id = domain.id
66-
left join
67-
`cloud`.`async_job` ON async_job.instance_id = user.id
68-
and async_job.instance_type = 'User'
69-
and async_job.job_status = 0;

engine/schema/resources/META-INF/db/schema-4930to41000.sql

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -255,26 +255,3 @@ CREATE TABLE `cloud`.`firewall_rules_dcidrs`(
255255
KEY `fk_firewall_dcidrs_firewall_rules` (`firewall_rule_id`),
256256
CONSTRAINT `fk_firewall_dcidrs_firewall_rules` FOREIGN KEY (`firewall_rule_id`) REFERENCES `firewall_rules` (`id`) ON DELETE CASCADE
257257
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
258-
259-
DROP TABLE IF EXISTS `cloud`.`netscaler_servicepackages`;
260-
CREATE TABLE `cloud`.`netscaler_servicepackages` (
261-
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
262-
`uuid` varchar(255) UNIQUE,
263-
`name` varchar(255) UNIQUE COMMENT 'name of the service package',
264-
`description` varchar(255) COMMENT 'description of the service package',
265-
PRIMARY KEY (`id`)
266-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
267-
268-
DROP TABLE IF EXISTS `cloud`.`external_netscaler_controlcenter`;
269-
CREATE TABLE `cloud`.`external_netscaler_controlcenter` (
270-
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
271-
`uuid` varchar(255) UNIQUE,
272-
`username` varchar(255) COMMENT 'username of the NCC',
273-
`password` varchar(255) COMMENT 'password of NCC',
274-
`ncc_ip` varchar(255) COMMENT 'IP of NCC Manager',
275-
`num_retries` bigint unsigned NOT NULL default 2 COMMENT 'Number of retries in ncc for command failure',
276-
PRIMARY KEY (`id`)
277-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
278-
279-
ALTER TABLE `cloud`.`sslcerts` ADD COLUMN `name` varchar(255) NULL default NULL COMMENT 'Name of the Certificate';
280-
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `service_package_id` varchar(255) NULL default NULL COMMENT 'Netscaler ControlCenter Service Package';

0 commit comments

Comments
 (0)