1 -- ============LICENSE_START=======================================================
2 -- Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
3 -- ================================================================================
4 -- Licensed under the Apache License, Version 2.0 (the "License");
5 -- you may not use this file except in compliance with the License.
6 -- You may obtain a copy of the License at
8 -- http://www.apache.org/licenses/LICENSE-2.0
10 -- Unless required by applicable law or agreed to in writing, software
11 -- distributed under the License is distributed on an "AS IS" BASIS,
12 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -- See the License for the specific language governing permissions and
14 -- limitations under the License.
15 -- ============LICENSE_END=========================================================
17 USE operationshistory;
19 CREATE TABLE IF NOT EXISTS operationshistory (
20 id INT(11) NOT NULL AUTO_INCREMENT,
21 closedLoopName VARCHAR(255) NOT NULL,
22 requestId VARCHAR(50),
23 actor VARCHAR(50) NOT NULL,
24 operation VARCHAR(50) NOT NULL,
25 target VARCHAR(50) NOT NULL,
26 starttime timestamp NOT NULL,
27 outcome VARCHAR(50) NOT NULL,
29 subrequestId VARCHAR(50),
30 endtime timestamp NULL DEFAULT current_timestamp,
34 DROP PROCEDURE IF EXISTS create_clreqid_index;
37 CREATE PROCEDURE create_clreqid_index()
39 DECLARE index_count INT DEFAULT 1;
41 SELECT count(index_name) INTO index_count FROM information_schema.statistics
42 WHERE table_schema=DATABASE() AND table_name='operationshistory' AND index_name='operationshistory_clreqid_index';
44 IF index_count = 0 THEN
45 CREATE INDEX operationshistory_clreqid_index ON operationshistory(requestId, closedLoopName);
52 CALL create_clreqid_index();
54 DROP PROCEDURE IF EXISTS create_target_index;
57 CREATE PROCEDURE create_target_index()
59 DECLARE index_count INT DEFAULT 1;
61 SELECT count(index_name) INTO index_count FROM information_schema.statistics
62 WHERE table_schema=DATABASE() AND table_name='operationshistory' AND index_name='operationshistory_target_index';
64 IF index_count = 0 THEN
65 CREATE INDEX operationshistory_target_index ON operationshistory(target, operation, actor, endtime);
70 CALL create_target_index();