From d402f37317026ca436f0ba056ff190b36ae85401 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 19 Apr 2022 16:10:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20fl?= =?UTF-8?q?yway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../db/migration/V115__1.20__release.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/backend/src/main/resources/db/migration/V115__1.20__release.sql b/backend/src/main/resources/db/migration/V115__1.20__release.sql index 0f778b3e23..98770afdd4 100644 --- a/backend/src/main/resources/db/migration/V115__1.20__release.sql +++ b/backend/src/main/resources/db/migration/V115__1.20__release.sql @@ -232,3 +232,27 @@ ALTER TABLE api_scenario DROP COLUMN use_url; -- 优化删除报告效率 CREATE INDEX api_definition_exec_result_integrated_report_id_IDX USING BTREE ON api_definition_exec_result (integrated_report_id); + +DROP PROCEDURE IF EXISTS schema_change_api; +DELIMITER // +CREATE PROCEDURE schema_change_api() BEGIN + DECLARE CurrentDatabase VARCHAR(100); + SELECT DATABASE() INTO CurrentDatabase; + IF NOT EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'api_definition_exec_result' AND index_name = 'create_time_index') THEN + ALTER TABLE `api_definition_exec_result` ADD INDEX create_time_index ( `create_time` ); + END IF; +END// +DELIMITER ; +CALL schema_change_api(); + +DROP PROCEDURE IF EXISTS schema_change_api_one; +DELIMITER // +CREATE PROCEDURE schema_change_api_one() BEGIN + DECLARE CurrentDatabase VARCHAR(100); + SELECT DATABASE() INTO CurrentDatabase; + IF EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'api_definition_exec_result' AND index_name = 'projectIdIndex') THEN + ALTER TABLE `api_definition_exec_result` DROP INDEX projectIdIndex; + END IF; +END// +DELIMITER ; +CALL schema_change_api_one();