From 1b6bbaf2360a24d04dff482a5fb7c4de69753a98 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 24 Nov 2021 13:11:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(flyway):=20=E4=BF=AE=E6=94=B9flyway?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V99__v1.15_release.sql | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/backend/src/main/resources/db/migration/V99__v1.15_release.sql b/backend/src/main/resources/db/migration/V99__v1.15_release.sql index 73a930ebfc..cd52f0de28 100644 --- a/backend/src/main/resources/db/migration/V99__v1.15_release.sql +++ b/backend/src/main/resources/db/migration/V99__v1.15_release.sql @@ -33,13 +33,39 @@ alter table api_scenario alter table api_scenario add environment_group_id varchar(50) null; -update api_scenario -set environment_json = api_scenario.scenario_definition -> '$.environmentMap' -where api_scenario.environment_json is null; +DELIMITER $$ +DROP PROCEDURE IF EXISTS proc_loop_test$$ +CREATE PROCEDURE proc_loop_test() +BEGIN + DECLARE int_val INT DEFAULT 0; + DECLARE size INT DEFAULT 10; + DECLARE count_scenario INT DEFAULT 0; + SELECT COUNT(1) INTO count_scenario FROM api_scenario; + test_loop : + LOOP + IF (int_val > count_scenario / size) + THEN + UPDATE api_scenario + SET environment_json = api_scenario.scenario_definition -> '$.environmentMap' + WHERE api_scenario.id IN (SELECT id FROM (SELECT id FROM api_scenario LIMIT int_val, size) l); + # + LEAVE test_loop; + END IF; -update api_scenario -set environment_type = 'JSON' -where environment_type is null; + UPDATE api_scenario + SET environment_json = api_scenario.scenario_definition -> '$.environmentMap' + WHERE api_scenario.id IN (SELECT id FROM (SELECT id FROM api_scenario LIMIT int_val, size) l); + + SET int_val = int_val + size; + END LOOP; +END$$ + +DELIMITER ; +CALL proc_loop_test(); +DROP PROCEDURE proc_loop_test; + + +update api_scenario set environment_type = 'JSON'; alter table test_plan_api_scenario add environment_type varchar(20) null comment '场景使用的环境类型';