This is an automated email from the ASF dual-hosted git repository.

wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 43a27e179e [Fix-17142] Add UK uniq_workflow_definition_code on 
t_ds_workflow_definition (#17151)
43a27e179e is described below

commit 43a27e179ea6d50c55bd0ac2950f16245c9e20ca
Author: Wenjun Ruan <[email protected]>
AuthorDate: Mon May 12 23:45:09 2025 +0800

    [Fix-17142] Add UK uniq_workflow_definition_code on 
t_ds_workflow_definition (#17151)
---
 .../src/main/resources/sql/dolphinscheduler_h2.sql   |  2 +-
 .../main/resources/sql/dolphinscheduler_mysql.sql    |  3 ++-
 .../resources/sql/dolphinscheduler_postgresql.sql    |  2 +-
 .../3.3.1_schema/mysql/dolphinscheduler_ddl.sql      | 20 ++++++++++++++++++++
 .../3.3.1_schema/mysql/dolphinscheduler_dml.sql      | 16 ++++++++++++++++
 .../3.3.1_schema/postgresql/dolphinscheduler_ddl.sql | 19 +++++++++++++++++++
 .../3.3.1_schema/postgresql/dolphinscheduler_dml.sql | 16 ++++++++++++++++
 7 files changed, 75 insertions(+), 3 deletions(-)

diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
index ce18e03fb1..08c57daeca 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
@@ -423,7 +423,7 @@ CREATE TABLE t_ds_workflow_definition
     update_time      datetime     DEFAULT NULL,
     PRIMARY KEY (id),
     UNIQUE KEY workflow_unique (name,project_code) USING BTREE,
-    UNIQUE KEY code_unique (code)
+    UNIQUE KEY uniq_workflow_definition_code (code)
 );
 
 -- ----------------------------
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
index 3091d7f337..bd256a0055 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
@@ -426,8 +426,9 @@ CREATE TABLE `t_ds_workflow_definition` (
   `execution_type` tinyint(4) DEFAULT '0' COMMENT 'execution_type 
0:parallel,1:serial wait,2:serial discard,3:serial priority',
   `create_time` datetime NOT NULL COMMENT 'create time',
   `update_time` datetime NOT NULL COMMENT 'update time',
-  PRIMARY KEY (`id`,`code`),
+  PRIMARY KEY (`id`),
   UNIQUE KEY `workflow_unique` (`name`,`project_code`) USING BTREE,
+  UNIQUE KEY uniq_workflow_definition_code (code),
   KEY `idx_project_code` (`project_code`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;
 
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
index 1d65eb93bf..ce8af49f0f 100644
--- 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
@@ -349,7 +349,7 @@ CREATE TABLE t_ds_workflow_definition (
   CONSTRAINT workflow_definition_unique UNIQUE (name, project_code)
 ) ;
 
-create index workflow_definition_index on t_ds_workflow_definition (code,id);
+create unique index uniq_workflow_definition_code on t_ds_workflow_definition 
(code);
 create index workflow_definition_index_project_code on 
t_ds_workflow_definition (project_code);
 
 --
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_ddl.sql
 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_ddl.sql
new file mode 100644
index 0000000000..63753af8c3
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_ddl.sql
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+ALTER TABLE t_ds_workflow_definition DROP PRIMARY KEY;
+ALTER TABLE t_ds_workflow_definition ADD PRIMARY KEY(id);
+ALTER TABLE t_ds_workflow_definition ADD UNIQUE KEY 
uniq_workflow_definition_code (code);
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_dml.sql
 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_dml.sql
new file mode 100644
index 0000000000..4a14f326b9
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/mysql/dolphinscheduler_dml.sql
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_ddl.sql
 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_ddl.sql
new file mode 100644
index 0000000000..aa83e576e0
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_ddl.sql
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+drop index if exists workflow_definition_index;
+create unique index uniq_workflow_definition_code on t_ds_workflow_definition 
(code);
\ No newline at end of file
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_dml.sql
 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_dml.sql
new file mode 100644
index 0000000000..4a14f326b9
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.1_schema/postgresql/dolphinscheduler_dml.sql
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/

Reply via email to