-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
schema-41810to41900.sql
185 lines (176 loc) · 9.33 KB
/
schema-41810to41900.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--;
-- Schema upgrade from 4.18.1.0 to 4.19.0.0
--;
ALTER TABLE `cloud`.`mshost` MODIFY COLUMN `state` varchar(25);
DROP VIEW IF EXISTS `cloud`.`async_job_view`;
CREATE VIEW `cloud`.`async_job_view` AS
select
account.id account_id,
account.uuid account_uuid,
account.account_name account_name,
account.type account_type,
domain.id domain_id,
domain.uuid domain_uuid,
domain.name domain_name,
domain.path domain_path,
user.id user_id,
user.uuid user_uuid,
async_job.id,
async_job.uuid,
async_job.job_cmd,
async_job.job_status,
async_job.job_process_status,
async_job.job_result_code,
async_job.job_result,
async_job.created,
async_job.removed,
async_job.instance_type,
async_job.instance_id,
async_job.job_executing_msid,
CASE
WHEN async_job.instance_type = 'Volume' THEN volumes.uuid
WHEN
async_job.instance_type = 'Template'
or async_job.instance_type = 'Iso'
THEN
vm_template.uuid
WHEN
async_job.instance_type = 'VirtualMachine'
or async_job.instance_type = 'ConsoleProxy'
or async_job.instance_type = 'SystemVm'
or async_job.instance_type = 'DomainRouter'
THEN
vm_instance.uuid
WHEN async_job.instance_type = 'Snapshot' THEN snapshots.uuid
WHEN async_job.instance_type = 'Host' THEN host.uuid
WHEN async_job.instance_type = 'StoragePool' THEN storage_pool.uuid
WHEN async_job.instance_type = 'IpAddress' THEN user_ip_address.uuid
WHEN async_job.instance_type = 'SecurityGroup' THEN security_group.uuid
WHEN async_job.instance_type = 'PhysicalNetwork' THEN physical_network.uuid
WHEN async_job.instance_type = 'TrafficType' THEN physical_network_traffic_types.uuid
WHEN async_job.instance_type = 'PhysicalNetworkServiceProvider' THEN physical_network_service_providers.uuid
WHEN async_job.instance_type = 'FirewallRule' THEN firewall_rules.uuid
WHEN async_job.instance_type = 'Account' THEN acct.uuid
WHEN async_job.instance_type = 'User' THEN us.uuid
WHEN async_job.instance_type = 'StaticRoute' THEN static_routes.uuid
WHEN async_job.instance_type = 'PrivateGateway' THEN vpc_gateways.uuid
WHEN async_job.instance_type = 'Counter' THEN counter.uuid
WHEN async_job.instance_type = 'Condition' THEN conditions.uuid
WHEN async_job.instance_type = 'AutoScalePolicy' THEN autoscale_policies.uuid
WHEN async_job.instance_type = 'AutoScaleVmProfile' THEN autoscale_vmprofiles.uuid
WHEN async_job.instance_type = 'AutoScaleVmGroup' THEN autoscale_vmgroups.uuid
ELSE null
END instance_uuid
from
`cloud`.`async_job`
left join
`cloud`.`account` ON async_job.account_id = account.id
left join
`cloud`.`domain` ON domain.id = account.domain_id
left join
`cloud`.`user` ON async_job.user_id = user.id
left join
`cloud`.`volumes` ON async_job.instance_id = volumes.id
left join
`cloud`.`vm_template` ON async_job.instance_id = vm_template.id
left join
`cloud`.`vm_instance` ON async_job.instance_id = vm_instance.id
left join
`cloud`.`snapshots` ON async_job.instance_id = snapshots.id
left join
`cloud`.`host` ON async_job.instance_id = host.id
left join
`cloud`.`storage_pool` ON async_job.instance_id = storage_pool.id
left join
`cloud`.`user_ip_address` ON async_job.instance_id = user_ip_address.id
left join
`cloud`.`security_group` ON async_job.instance_id = security_group.id
left join
`cloud`.`physical_network` ON async_job.instance_id = physical_network.id
left join
`cloud`.`physical_network_traffic_types` ON async_job.instance_id = physical_network_traffic_types.id
left join
`cloud`.`physical_network_service_providers` ON async_job.instance_id = physical_network_service_providers.id
left join
`cloud`.`firewall_rules` ON async_job.instance_id = firewall_rules.id
left join
`cloud`.`account` acct ON async_job.instance_id = acct.id
left join
`cloud`.`user` us ON async_job.instance_id = us.id
left join
`cloud`.`static_routes` ON async_job.instance_id = static_routes.id
left join
`cloud`.`vpc_gateways` ON async_job.instance_id = vpc_gateways.id
left join
`cloud`.`counter` ON async_job.instance_id = counter.id
left join
`cloud`.`conditions` ON async_job.instance_id = conditions.id
left join
`cloud`.`autoscale_policies` ON async_job.instance_id = autoscale_policies.id
left join
`cloud`.`autoscale_vmprofiles` ON async_job.instance_id = autoscale_vmprofiles.id
left join
`cloud`.`autoscale_vmgroups` ON async_job.instance_id = autoscale_vmgroups.id;
-- Invalidate existing console_session records
UPDATE `cloud`.`console_session` SET removed=now();
-- Modify acquired column in console_session to datetime type
ALTER TABLE `cloud`.`console_session` DROP `acquired`, ADD `acquired` datetime COMMENT 'When the session was acquired' AFTER `host_id`;
-- create_public_parameter_on_roles. #6960
ALTER TABLE `cloud`.`roles` ADD COLUMN `public_role` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Indicates whether the role will be visible to all users (public) or only to root admins (private). If this parameter is not specified during the creation of the role its value will be defaulted to true (public).';
-- Add tables for VM Scheduler
DROP TABLE IF EXISTS `cloud`.`vm_schedule`;
CREATE TABLE `cloud`.`vm_schedule` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`vm_id` bigint unsigned NOT NULL,
`uuid` varchar(40) NOT NULL COMMENT 'schedule uuid',
`description` varchar(1024) COMMENT 'description of the vm schedule',
`schedule` varchar(255) NOT NULL COMMENT 'schedule frequency in cron format',
`timezone` varchar(100) NOT NULL COMMENT 'the timezone in which the schedule time is specified',
`action` varchar(20) NOT NULL COMMENT 'action to perform',
`enabled` int(1) NOT NULL COMMENT 'Enabled or disabled',
`start_date` datetime NOT NULL COMMENT 'start time for this schedule',
`end_date` datetime COMMENT 'end time for this schedule',
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
INDEX `i_vm_schedule__vm_id`(`vm_id`),
INDEX `i_vm_schedule__enabled_end_date`(`enabled`, `end_date`),
CONSTRAINT `fk_vm_schedule__vm_id` FOREIGN KEY (`vm_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `cloud`.`vm_scheduled_job`;
CREATE TABLE `cloud`.`vm_scheduled_job` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`vm_id` bigint unsigned NOT NULL,
`vm_schedule_id` bigint unsigned NOT NULL,
`uuid` varchar(40) NOT NULL COMMENT 'scheduled job uuid',
`action` varchar(20) NOT NULL COMMENT 'action to perform',
`scheduled_timestamp` datetime NOT NULL COMMENT 'Time at which the action is taken',
`async_job_id` bigint unsigned DEFAULT NULL COMMENT 'If this schedule is being executed, it is the id of the create aysnc_job. Before that it is null',
PRIMARY KEY (`id`),
UNIQUE KEY (`vm_schedule_id`, `scheduled_timestamp`),
INDEX `i_vm_scheduled_job__scheduled_timestamp`(`scheduled_timestamp`),
INDEX `i_vm_scheduled_job__vm_id`(`vm_id`),
CONSTRAINT `fk_vm_scheduled_job__vm_id` FOREIGN KEY (`vm_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_vm_scheduled_job__vm_schedule_id` FOREIGN KEY (`vm_schedule_id`) REFERENCES `vm_schedule`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Add support for different cluster types for kubernetes
ALTER TABLE `cloud`.`kubernetes_cluster` ADD COLUMN `cluster_type` varchar(64) DEFAULT 'CloudManaged' COMMENT 'type of cluster';
ALTER TABLE `cloud`.`kubernetes_cluster` MODIFY COLUMN `kubernetes_version_id` bigint unsigned NULL COMMENT 'the ID of the Kubernetes version of this Kubernetes cluster';
-- Set removed state for all removed accounts
UPDATE `cloud`.`account` SET state='removed' WHERE `removed` IS NOT NULL;