From 82fee46d709593799d54f1587b8e783b7c6bfc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=96=E9=B8=A3?= Date: Wed, 6 May 2020 19:31:56 +0800 Subject: [PATCH] unique check before import ProcessDefinitions --- .../api/service/ProcessDefinitionService.java | 7 +++++++ sql/dolphinscheduler_mysql.sql | 1 + 2 files changed, 8 insertions(+) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java index 4fdafa46fa..6727ccd894 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java @@ -782,6 +782,13 @@ public class ProcessDefinitionService extends BaseDAGService { processDefinitionName, 1); } + // unique check + result = verifyProcessDefinitionName(loginUser, currentProjectName, processDefinitionName); + Status status = (Status) result.get(Constants.STATUS); + if (!Status.SUCCESS.equals(status)) { + return false; + } + // get create process result Map createProcessResult = getCreateProcessResult(loginUser, diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index c0c81dcb21..8ff2667f5f 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -415,6 +415,7 @@ CREATE TABLE `t_ds_process_definition` ( `modify_by` varchar(255) DEFAULT NULL, `resource_ids` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), + UNIQUE KEY `process_definition_unique` (`name`,`project_id`), KEY `process_definition_index` (`project_id`,`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;