From dbfbe1476204013b81af7d27ad54cc2d64b116e2 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 2 Jun 2023 14:38:27 +0800 Subject: [PATCH] build: flyway init --- backend/app/src/main/resources/commons.properties | 3 ++- .../migration/3.0.0/ddl/V3.0.0_4__project_ddl.sql | 8 ++++---- .../io/metersphere/sdk/controller/LoginController.java | 2 +- .../java/io/metersphere/sdk/util/FilterChainUtils.java | 4 ++-- .../api/controller/ApiDefinitionControllerTests.java | 2 +- .../functional/controller/CaseReviewControllerTests.java | 2 +- .../metersphere/issue/controller/IssueControllerTest.java | 2 +- .../controller/ProjectApplicationControllerTests.java | 2 +- .../project/controller/ProjectControllerTests.java | 2 +- .../system/controller/UserControllerTests.java | 2 +- .../plan/controller/TestPlanApiCaseControllerTests.java | 2 +- .../plan/controller/TestPlanControllerTests.java | 2 +- 12 files changed, 17 insertions(+), 16 deletions(-) diff --git a/backend/app/src/main/resources/commons.properties b/backend/app/src/main/resources/commons.properties index 7c8b5e9fb3..8de3c6da0a 100644 --- a/backend/app/src/main/resources/commons.properties +++ b/backend/app/src/main/resources/commons.properties @@ -1,6 +1,7 @@ spring.application.name=metersphere management.server.port=7071 server.port=8081 +server.servlet.context-path=/backend # gzip server.compression.enabled=true server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css,text/javascript,image/jpeg @@ -55,7 +56,7 @@ mybatis.configuration.map-underscore-to-camel-case=true # view spring.mvc.throw-exception-if-no-handler-found=true # flyway enable -spring.flyway.enabled=false +spring.flyway.enabled=true spring.flyway.baseline-on-migrate=true spring.flyway.locations=classpath:migration spring.flyway.table=metersphere_version diff --git a/backend/app/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_ddl.sql b/backend/app/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_ddl.sql index da0b0e57ee..405101f3df 100644 --- a/backend/app/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_ddl.sql +++ b/backend/app/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_ddl.sql @@ -1,7 +1,7 @@ -- set innodb lock wait timeout SET SESSION innodb_lock_wait_timeout = 7200; -CREATE TABLE `project` +CREATE TABLE IF NOT EXISTS `project` ( `id` VARCHAR(50) NOT NULL COMMENT '项目ID', `workspace_id` VARCHAR(50) NOT NULL COMMENT '工作空间ID', @@ -17,7 +17,7 @@ CREATE TABLE `project` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT ='项目'; -CREATE TABLE `project_application` +CREATE TABLE IF NOT EXISTS `project_application` ( `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', `type` VARCHAR(50) NOT NULL COMMENT '配置项', @@ -30,7 +30,7 @@ CREATE TABLE `project_application` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT ='项目应用'; -CREATE TABLE `project_extend` +CREATE TABLE IF NOT EXISTS `project_extend` ( `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', `tapd_id` VARCHAR(50) DEFAULT NULL, @@ -49,7 +49,7 @@ CREATE TABLE `project_extend` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT ='项目扩展'; -CREATE TABLE `project_version` +CREATE TABLE IF NOT EXISTS `project_version` ( `id` VARCHAR(50) NOT NULL COMMENT '版本ID', `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LoginController.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LoginController.java index 10be1eb015..1040af852e 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LoginController.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LoginController.java @@ -53,7 +53,7 @@ public class LoginController { return null; } - @PostMapping(value = "/signin") + @PostMapping(value = "/login") public ResultHolder login(@RequestBody LoginRequest request) { SessionUser sessionUser = SessionUtils.getUser(); if (sessionUser != null) { diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java index 83a3b6ef70..e8927bf210 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java @@ -8,8 +8,8 @@ public class FilterChainUtils { public static Map loadBaseFilterChain() { Map filterChainDefinitionMap = new HashMap<>(); filterChainDefinitionMap.put("/*.html", "anon"); - filterChainDefinitionMap.put("/signin", "anon"); - filterChainDefinitionMap.put("/ldap/signin", "anon"); + filterChainDefinitionMap.put("/login", "anon"); + filterChainDefinitionMap.put("/ldap/login", "anon"); filterChainDefinitionMap.put("/ldap/open", "anon"); filterChainDefinitionMap.put("/signout", "anon"); filterChainDefinitionMap.put("/is-login", "anon"); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java index 542e80756c..0eb5744932 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java @@ -50,7 +50,7 @@ public class ApiDefinitionControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/functional-test/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java b/backend/services/functional-test/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java index 59e3b3b94d..af7dc52f0e 100644 --- a/backend/services/functional-test/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java +++ b/backend/services/functional-test/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java @@ -35,7 +35,7 @@ public class CaseReviewControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/issue-management/src/test/java/io/metersphere/issue/controller/IssueControllerTest.java b/backend/services/issue-management/src/test/java/io/metersphere/issue/controller/IssueControllerTest.java index 1d451127d0..eda2373e82 100644 --- a/backend/services/issue-management/src/test/java/io/metersphere/issue/controller/IssueControllerTest.java +++ b/backend/services/issue-management/src/test/java/io/metersphere/issue/controller/IssueControllerTest.java @@ -37,7 +37,7 @@ public class IssueControllerTest { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java index 10799fa4ee..f731ca47a9 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java @@ -32,7 +32,7 @@ public class ProjectApplicationControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java index bc28f71b59..2e55d22c83 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java @@ -36,7 +36,7 @@ public class ProjectControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java index e5193afc43..4569b3553e 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserControllerTests.java @@ -34,7 +34,7 @@ public class UserControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java index de343e7a12..194ea03da8 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java @@ -46,7 +46,7 @@ public class TestPlanApiCaseControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java index 6bacf69dac..9ae98f2dec 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java @@ -53,7 +53,7 @@ public class TestPlanControllerTests { @Test @Order(0) public void login() throws Exception { - MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/signin") + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk())