You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2022/08/02 08:27:41 UTC
[dolphinscheduler] branch 3.0.0-prepare updated: [fix] Make DDL work in version 3.0
This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch 3.0.0-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/3.0.0-prepare by this push:
new 3915c4f40a [fix] Make DDL work in version 3.0
3915c4f40a is described below
commit 3915c4f40a1e533645483dbf51e9ffbb0c460d46
Author: Jiajie Zhong <zh...@gmail.com>
AuthorDate: Mon Aug 1 18:47:07 2022 +0800
[fix] Make DDL work in version 3.0
* Add missing database ddl
* Because postgres supported `if not exist` and `if exists` syntax
so we can use bare SQL directly instead of store process
---
.../resources/sql/dolphinscheduler_postgresql.sql | 22 +-
.../2.0.2_schema/mysql/dolphinscheduler_ddl.sql | 22 +
.../postgresql/dolphinscheduler_ddl.sql | 13 +-
.../mysql}/dolphinscheduler_ddl.sql | 5 +
.../mysql/dolphinscheduler_dml.sql | 0
.../postgresql/dolphinscheduler_ddl.sql | 20 +-
.../postgresql/dolphinscheduler_dml.sql | 0
.../2.0.4_schema/mysql/dolphinscheduler_ddl.sql | 5 +-
.../2.0.4_schema/mysql/dolphinscheduler_dml.sql | 2 +-
.../postgresql/dolphinscheduler_ddl.sql | 31 ++
.../postgresql/dolphinscheduler_dml.sql | 2 +-
.../mysql/dolphinscheduler_ddl.sql} | 0
.../mysql}/dolphinscheduler_dml.sql | 0
.../postgresql/dolphinscheduler_ddl.sql | 0
.../postgresql}/dolphinscheduler_dml.sql | 0
.../mysql/dolphinscheduler_ddl.sql} | 30 +-
.../mysql/dolphinscheduler_dml.sql | 0
.../postgresql/dolphinscheduler_ddl.sql} | 36 +-
.../postgresql}/dolphinscheduler_dml.sql | 1 +
.../3.0.0_schema/mysql/dolphinscheduler_ddl.sql | 501 +++++++++++++++++++--
.../postgresql/dolphinscheduler_ddl.sql | 282 ++++++------
21 files changed, 746 insertions(+), 226 deletions(-)
diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
index a4077bd90f..9bd84e1e5d 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
@@ -856,23 +856,6 @@ CREATE TABLE t_ds_worker_group (
CONSTRAINT name_unique UNIQUE (name)
) ;
---
--- Table structure for table t_ds_worker_server
---
-
-DROP TABLE IF EXISTS t_ds_worker_server;
-CREATE TABLE t_ds_worker_server (
- id int NOT NULL ,
- host varchar(45) DEFAULT NULL ,
- port int DEFAULT NULL ,
- zk_directory varchar(64) DEFAULT NULL ,
- res_info varchar(255) DEFAULT NULL ,
- create_time timestamp DEFAULT NULL ,
- last_heartbeat_time timestamp DEFAULT NULL ,
- PRIMARY KEY (id)
-) ;
-
-
DROP SEQUENCE IF EXISTS t_ds_access_token_id_sequence;
CREATE SEQUENCE t_ds_access_token_id_sequence;
ALTER TABLE t_ds_access_token ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_access_token_id_sequence');
@@ -961,13 +944,10 @@ ALTER TABLE t_ds_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_version_id_se
DROP SEQUENCE IF EXISTS t_ds_worker_group_id_sequence;
CREATE SEQUENCE t_ds_worker_group_id_sequence;
ALTER TABLE t_ds_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence');
-DROP SEQUENCE IF EXISTS t_ds_worker_server_id_sequence;
-CREATE SEQUENCE t_ds_worker_server_id_sequence;
-ALTER TABLE t_ds_worker_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence');
-- Records of t_ds_user?user : admin , password : dolphinscheduler123
INSERT INTO t_ds_user(user_name, user_password, user_type, email, phone, tenant_id, state, create_time, update_time, time_zone)
-VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22', 'Asia/Shanghai');
+VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22', null);
-- Records of t_ds_alertgroup, default admin warning group
INSERT INTO t_ds_alertgroup(alert_instance_ids, create_user_id, group_name, description, create_time, update_time)
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/mysql/dolphinscheduler_ddl.sql
index e492693b8a..89d5c53c59 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/mysql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/mysql/dolphinscheduler_ddl.sql
@@ -17,6 +17,7 @@
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
+
-- uc_dolphin_T_t_ds_process_instance_A_restart_time
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_restart_time;
delimiter d//
@@ -36,3 +37,24 @@ d//
delimiter ;
CALL uc_dolphin_T_t_ds_process_instance_A_restart_time();
DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_restart_time;
+
+
+-- uc_dolphin_T_t_ds_process_task_relation_A_pc_pd_index
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_task_relation_A_pc_pd_index;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_process_task_relation_A_pc_pd_index()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM information_schema.STATISTICS
+ WHERE TABLE_NAME='t_ds_process_task_relation'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME ='project_code_process_definition_code_index')
+ THEN
+ALTER TABLE `t_ds_process_task_relation` ADD KEY `project_code_process_definition_code_index`(`project_code`,`process_definition_code`) USING BTREE;
+END IF;
+END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_process_task_relation_A_pc_pd_index();
+DROP PROCEDURE uc_dolphin_T_t_ds_process_task_relation_A_pc_pd_index;
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql
index 79be113825..75be01f0c1 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql
@@ -23,14 +23,17 @@ CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
- v_schema varchar;
+v_schema varchar;
BEGIN
---get schema name
v_schema =current_schema();
- EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "restart_time" timestamp DEFAULT NULL';
- return 'Success!';
- exception when others then
+EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "restart_time" timestamp DEFAULT NULL';
+
+EXECUTE 'CREATE INDEX IF NOT EXISTS project_code_process_definition_code_index ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation USING Btree("project_code","process_definition_code")';
+
+return 'Success!';
+exception when others then
---Raise EXCEPTION '(%)',SQLERRM;
return SQLERRM;
END;
@@ -38,4 +41,4 @@ $BODY$;
select dolphin_update_metadata();
-d//
+d//
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/mysql/dolphinscheduler_ddl.sql
similarity index 62%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/mysql/dolphinscheduler_ddl.sql
index 4a14f326b9..a95858d936 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/mysql/dolphinscheduler_ddl.sql
@@ -14,3 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `task_params` longtext COMMENT 'job custom parameters' AFTER `app_link`;
+ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_code` (`project_code`, `process_definition_code`) USING BTREE;
+ALTER TABLE `t_ds_process_task_relation_log` ADD KEY `idx_process_code_version` (`process_definition_code`,`process_definition_version`) USING BTREE;
+ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_code_version` (`code`,`version`) USING BTREE;
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/mysql/dolphinscheduler_dml.sql
similarity index 100%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/mysql/dolphinscheduler_dml.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/postgresql/dolphinscheduler_ddl.sql
similarity index 54%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/postgresql/dolphinscheduler_ddl.sql
index 79be113825..a828a1aa4d 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.2_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/postgresql/dolphinscheduler_ddl.sql
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
delimiter d//
CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
)
@@ -23,14 +24,23 @@ CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
- v_schema varchar;
+v_schema varchar;
BEGIN
---get schema name
v_schema =current_schema();
- EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "restart_time" timestamp DEFAULT NULL';
- return 'Success!';
- exception when others then
+EXECUTE 'DROP INDEX IF EXISTS "idx_code_relation"';
+EXECUTE 'DROP INDEX IF EXISTS "idx_process_code_version_relation_log"';
+EXECUTE 'DROP INDEX IF EXISTS "idx_code_version_task_log"';
+EXECUTE 'CREATE INDEX IF NOT EXISTS idx_code_relation ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation USING Btree("project_code","process_definition_code")';
+EXECUTE 'CREATE INDEX IF NOT EXISTS idx_process_code_version_relation_log ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation_log USING Btree("process_definition_code","process_definition_version")';
+EXECUTE 'CREATE INDEX IF NOT EXISTS idx_code_version_task_log ON ' || quote_ident(v_schema) ||'.t_ds_task_definition_log USING Btree("code","version")';
+
+EXECUTE 'ALTER TABLE t_ds_resources alter COLUMN is_directory TYPE bool using (is_directory::bool)';
+EXECUTE 'ALTER TABLE t_ds_resources alter COLUMN is_directory SET DEFAULT FALSE';
+
+return 'Success!';
+exception when others then
---Raise EXCEPTION '(%)',SQLERRM;
return SQLERRM;
END;
@@ -38,4 +48,4 @@ $BODY$;
select dolphin_update_metadata();
-d//
+d//
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/postgresql/dolphinscheduler_dml.sql
similarity index 100%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_dml.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.3_schema/postgresql/dolphinscheduler_dml.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_ddl.sql
index 38964cc551..996e009dc2 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_ddl.sql
@@ -13,4 +13,7 @@
* 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.
-*/
\ No newline at end of file
+*/
+
+ALTER TABLE `t_ds_task_instance` ADD INDEX `idx_code_version` (`task_code`, `task_definition_version`) USING BTREE;
+ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_project_code` (`project_code`) USING BTREE;
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
index 4a14f326b9..38964cc551 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
@@ -13,4 +13,4 @@
* 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.
-*/
+*/
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
index 4a14f326b9..6d5c3c0f7e 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
@@ -14,3 +14,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+delimiter d//
+CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
+ )
+ RETURNS character varying
+ LANGUAGE 'plpgsql'
+ COST 100
+ VOLATILE PARALLEL UNSAFE
+AS $BODY$
+DECLARE
+v_schema varchar;
+BEGIN
+ ---get schema name
+ v_schema =current_schema();
+
+EXECUTE 'DROP INDEX IF EXISTS "idx_task_definition_log_project_code"';
+EXECUTE 'CREATE INDEX IF NOT EXISTS idx_task_definition_log_project_code ON ' || quote_ident(v_schema) ||'.t_ds_task_definition_log USING Btree("project_code")';
+
+EXECUTE 'DROP INDEX IF EXISTS "idx_task_instance_code_version"';
+EXECUTE 'CREATE INDEX IF NOT EXISTS idx_task_instance_code_version ON' || quote_ident(v_schema) ||'.t_ds_task_instance USING Btree("task_code","task_definition_version")';
+
+return 'Success!';
+exception when others then
+ ---Raise EXCEPTION '(%)',SQLERRM;
+ return SQLERRM;
+END;
+$BODY$;
+
+select dolphin_update_metadata();
+
+d//
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_dml.sql
index 4a14f326b9..38964cc551 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_dml.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_dml.sql
@@ -13,4 +13,4 @@
* 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.
-*/
+*/
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/mysql/dolphinscheduler_ddl.sql
similarity index 100%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/mysql/dolphinscheduler_dml.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/mysql/dolphinscheduler_ddl.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/postgresql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/mysql/dolphinscheduler_dml.sql
similarity index 100%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/postgresql/dolphinscheduler_dml.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/mysql/dolphinscheduler_dml.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/postgresql/dolphinscheduler_ddl.sql
similarity index 100%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/postgresql/dolphinscheduler_ddl.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/postgresql/dolphinscheduler_ddl.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/postgresql/dolphinscheduler_dml.sql
similarity index 100%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.5_schema/postgresql/dolphinscheduler_dml.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_ddl.sql
similarity index 55%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_ddl.sql
index 8e2bbe601c..45f8acd4da 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_ddl.sql
@@ -15,12 +15,24 @@
* limitations under the License.
*/
-ALTER TABLE "t_ds_process_definition" DROP CONSTRAINT "t_ds_process_definition_pkey";
-ALTER TABLE "t_ds_process_definition" DROP CONSTRAINT "process_definition_unique";
-DROP INDEX "process_definition_index";
-ALTER TABLE "t_ds_process_definition" DROP "process_definition_json";
-ALTER TABLE "t_ds_process_definition" DROP "connects";
-ALTER TABLE "t_ds_process_definition" DROP "receivers";
-ALTER TABLE "t_ds_process_definition" DROP "receivers_cc";
-ALTER TABLE "t_ds_process_definition" DROP "modify_by";
-ALTER TABLE "t_ds_process_definition" DROP "resource_ids";
+SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
+
+-- uc_dolphin_T_t_ds_resources_R_full_name
+drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_resources_R_full_name;
+delimiter d//
+CREATE PROCEDURE uc_dolphin_T_t_ds_resources_R_full_name()
+BEGIN
+ IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE TABLE_NAME='t_ds_resources'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME ='full_name')
+ THEN
+ALTER TABLE t_ds_resources MODIFY COLUMN `full_name` varchar(128);
+END IF;
+END;
+
+d//
+
+delimiter ;
+CALL uc_dolphin_T_t_ds_resources_R_full_name;
+DROP PROCEDURE uc_dolphin_T_t_ds_resources_R_full_name;
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_dml.sql
similarity index 100%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/mysql/dolphinscheduler_dml.sql
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_ddl.sql
similarity index 57%
rename from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql
rename to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_ddl.sql
index dfde96209e..14a20fcd8e 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_ddl.sql
@@ -15,12 +15,30 @@
* limitations under the License.
*/
-alter table t_ds_process_definition drop primary key, ADD PRIMARY KEY (`id`,`code`);
-ALTER TABLE t_ds_process_definition drop KEY `process_definition_unique`;
-ALTER TABLE t_ds_process_definition drop KEY `process_definition_index`;
-alter table t_ds_process_definition drop process_definition_json;
-alter table t_ds_process_definition drop connects;
-alter table t_ds_process_definition drop receivers;
-alter table t_ds_process_definition drop receivers_cc;
-alter table t_ds_process_definition drop modify_by;
-alter table t_ds_process_definition drop resource_ids;
\ No newline at end of file
+delimiter d//
+CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
+ )
+ RETURNS character varying
+ LANGUAGE 'plpgsql'
+ COST 100
+ VOLATILE PARALLEL UNSAFE
+AS $BODY$
+DECLARE
+ v_schema varchar;
+BEGIN
+ ---get schema name
+ v_schema =current_schema();
+
+ --- alter column
+ EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_resources ALTER COLUMN full_name Type varchar(128)';
+
+ return 'Success!';
+ exception when others then
+ ---Raise EXCEPTION '(%)',SQLERRM;
+ return SQLERRM;
+END;
+$BODY$;
+
+select dolphin_update_metadata();
+
+d//
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_dml.sql
similarity index 99%
copy from dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
copy to dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_dml.sql
index 4a14f326b9..5f26e3515d 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.4_schema/mysql/dolphinscheduler_dml.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.6_schema/postgresql/dolphinscheduler_dml.sql
@@ -14,3 +14,4 @@
* 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.0.0_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql
index 44ad629814..9a19da50a6 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql
@@ -17,26 +17,6 @@
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
--- uc_dolphin_T_t_ds_resources_R_full_name
-drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_resources_R_full_name;
-delimiter d//
-CREATE PROCEDURE uc_dolphin_T_t_ds_resources_R_full_name()
-BEGIN
- IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
- WHERE TABLE_NAME='t_ds_resources'
- AND TABLE_SCHEMA=(SELECT DATABASE())
- AND COLUMN_NAME ='full_name')
- THEN
-ALTER TABLE t_ds_resources MODIFY COLUMN `full_name` varchar(128);
-END IF;
-END;
-
-d//
-
-delimiter ;
-CALL uc_dolphin_T_t_ds_resources_R_full_name;
-DROP PROCEDURE uc_dolphin_T_t_ds_resources_R_full_name;
-
-- uc_dolphin_T_t_ds_alert_R_sign
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alert_R_sign;
delimiter d//
@@ -59,39 +39,443 @@ CALL uc_dolphin_T_t_ds_alert_R_sign;
DROP PROCEDURE uc_dolphin_T_t_ds_alert_R_sign;
-- add unique key to t_ds_relation_project_user
-ALTER TABLE t_ds_relation_project_user ADD UNIQUE KEY uniq_uid_pid(user_id,project_id);
+drop PROCEDURE if EXISTS add_t_ds_relation_project_user_uk_uniq_uid_pid;
+delimiter d//
+CREATE PROCEDURE add_t_ds_relation_project_user_uk_uniq_uid_pid()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_relation_project_user'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='uniq_uid_pid')
+ THEN
+ALTER TABLE t_ds_relation_project_user ADD UNIQUE KEY uniq_uid_pid(user_id, project_id);
+END IF;
+END;
+
+d//
+
+delimiter ;
+CALL add_t_ds_relation_project_user_uk_uniq_uid_pid;
+DROP PROCEDURE add_t_ds_relation_project_user_uk_uniq_uid_pid;
+
+-- drop t_ds_relation_project_user key user_id_index
+drop PROCEDURE if EXISTS drop_t_ds_relation_project_user_key_user_id_index;
+delimiter d//
+CREATE PROCEDURE drop_t_ds_relation_project_user_key_user_id_index()
+BEGIN
+ IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_relation_project_user'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='user_id_index')
+ THEN
+ALTER TABLE `t_ds_relation_project_user` DROP KEY `user_id_index`;
+END IF;
+END;
+d//
+delimiter ;
+CALL drop_t_ds_relation_project_user_key_user_id_index;
+DROP PROCEDURE drop_t_ds_relation_project_user_key_user_id_index;
-- add unique key to t_ds_project
+drop PROCEDURE if EXISTS add_t_ds_project_uk_unique_name;
+delimiter d//
+CREATE PROCEDURE add_t_ds_project_uk_unique_name()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_project'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='unique_name')
+ THEN
ALTER TABLE t_ds_project ADD UNIQUE KEY unique_name(name);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_project_uk_unique_name;
+DROP PROCEDURE add_t_ds_project_uk_unique_name;
+
+drop PROCEDURE if EXISTS add_t_ds_project_uk_unique_code;
+delimiter d//
+CREATE PROCEDURE add_t_ds_project_uk_unique_code()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_project'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='unique_code')
+ THEN
ALTER TABLE t_ds_project ADD UNIQUE KEY unique_code(code);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_project_uk_unique_code;
+DROP PROCEDURE add_t_ds_project_uk_unique_code;
-- add unique key to t_ds_queue
+drop PROCEDURE if EXISTS add_t_ds_queue_uk_unique_queue_name;
+delimiter d//
+CREATE PROCEDURE add_t_ds_queue_uk_unique_queue_name()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_queue'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='unique_queue_name')
+ THEN
ALTER TABLE t_ds_queue ADD UNIQUE KEY unique_queue_name(queue_name);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_queue_uk_unique_queue_name;
+DROP PROCEDURE add_t_ds_queue_uk_unique_queue_name;
-- add unique key to t_ds_udfs
+drop PROCEDURE if EXISTS add_t_ds_udfs_uk_unique_func_name;
+delimiter d//
+CREATE PROCEDURE add_t_ds_udfs_uk_unique_func_name()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_udfs'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='unique_func_name')
+ THEN
ALTER TABLE t_ds_udfs ADD UNIQUE KEY unique_func_name(func_name);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_udfs_uk_unique_func_name;
+DROP PROCEDURE add_t_ds_udfs_uk_unique_func_name;
-- add unique key to t_ds_tenant
+drop PROCEDURE if EXISTS add_t_ds_tenant_uk_unique_tenant_code;
+delimiter d//
+CREATE PROCEDURE add_t_ds_tenant_uk_unique_tenant_code()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_tenant'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='unique_tenant_code')
+ THEN
ALTER TABLE t_ds_tenant ADD UNIQUE KEY unique_tenant_code(tenant_code);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_tenant_uk_unique_tenant_code;
+DROP PROCEDURE add_t_ds_tenant_uk_unique_tenant_code;
+-- ALTER TABLE `t_ds_task_instance` ADD INDEX `idx_code_version` (`task_code`, `task_definition_version`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_task_instance_uk_idx_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_instance_uk_idx_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_task_instance'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_code_version')
+ THEN
ALTER TABLE `t_ds_task_instance` ADD INDEX `idx_code_version` (`task_code`, `task_definition_version`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_instance_uk_idx_code_version;
+DROP PROCEDURE add_t_ds_task_instance_uk_idx_code_version;
+
+-- ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `task_params` longtext COMMENT 'job custom parameters' AFTER `app_link`;
+drop PROCEDURE if EXISTS modify_t_ds_task_instance_col_task_params;
+delimiter d//
+CREATE PROCEDURE modify_t_ds_task_instance_col_task_params()
+BEGIN
+ IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_instance'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME ='task_params')
+ THEN
ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `task_params` longtext COMMENT 'job custom parameters' AFTER `app_link`;
+END IF;
+END;
+d//
+delimiter ;
+CALL modify_t_ds_task_instance_col_task_params;
+DROP PROCEDURE modify_t_ds_task_instance_col_task_params;
+
+-- ALTER TABLE `t_ds_task_instance` ADD COLUMN `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id';
+drop PROCEDURE if EXISTS add_t_ds_task_instance_col_task_group_id;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_instance_col_task_group_id()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_instance'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME ='task_group_id')
+ THEN
+ALTER TABLE `t_ds_task_instance` ADD COLUMN `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id' after `var_pool`;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_instance_col_task_group_id;
+DROP PROCEDURE add_t_ds_task_instance_col_task_group_id;
+
+-- ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_code` (`project_code`, `process_definition_code`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_process_task_relation_key_idx_code;
+delimiter d//
+CREATE PROCEDURE add_t_ds_process_task_relation_key_idx_code()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_process_task_relation'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_code')
+ THEN
ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_code` (`project_code`, `process_definition_code`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_process_task_relation_key_idx_code;
+DROP PROCEDURE add_t_ds_process_task_relation_key_idx_code;
+
+-- ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_pre_task_code_version` (`pre_task_code`,`pre_task_version`);
+drop PROCEDURE if EXISTS add_t_ds_process_task_relation_key_idx_pre_task_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_process_task_relation_key_idx_pre_task_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_process_task_relation'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_pre_task_code_version')
+ THEN
ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_pre_task_code_version` (`pre_task_code`,`pre_task_version`);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_process_task_relation_key_idx_pre_task_code_version;
+DROP PROCEDURE add_t_ds_process_task_relation_key_idx_pre_task_code_version;
+
+-- ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_post_task_code_version` (`post_task_code`,`post_task_version`);
+drop PROCEDURE if EXISTS add_t_ds_process_task_relation_key_idx_post_task_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_process_task_relation_key_idx_post_task_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_process_task_relation'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_post_task_code_version')
+ THEN
ALTER TABLE `t_ds_process_task_relation` ADD KEY `idx_post_task_code_version` (`post_task_code`,`post_task_version`);
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_process_task_relation_key_idx_post_task_code_version;
+DROP PROCEDURE add_t_ds_process_task_relation_key_idx_post_task_code_version;
+
+-- ALTER TABLE `t_ds_process_task_relation_log` ADD KEY `idx_process_code_version` (`process_definition_code`,`process_definition_version`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_process_task_relation_key_idx_process_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_process_task_relation_key_idx_process_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_process_task_relation_log'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_process_code_version')
+ THEN
ALTER TABLE `t_ds_process_task_relation_log` ADD KEY `idx_process_code_version` (`process_definition_code`,`process_definition_version`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_process_task_relation_key_idx_process_code_version;
+DROP PROCEDURE add_t_ds_process_task_relation_key_idx_process_code_version;
+-- ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_project_code` (`project_code`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_log_key_idx_process_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_log_key_idx_process_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_task_definition_log'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_project_code')
+ THEN
ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_project_code` (`project_code`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_log_key_idx_process_code_version;
+DROP PROCEDURE add_t_ds_task_definition_log_key_idx_process_code_version;
+
+-- ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_code_version` (`code`,`version`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_log_key_idx_code_version;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_log_key_idx_code_version()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_task_definition_log'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_code_version')
+ THEN
ALTER TABLE `t_ds_task_definition_log` ADD INDEX `idx_code_version` (`code`,`version`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_log_key_idx_code_version;
+DROP PROCEDURE add_t_ds_task_definition_log_key_idx_code_version;
+
+-- alter table t_ds_task_definition_log add `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `resource_ids`;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_log_col_task_group_id;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_log_col_task_group_id()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_definition_log'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='task_group_id')
+ THEN
alter table t_ds_task_definition_log add `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `resource_ids`;
-alter table t_ds_task_definition_log add `task_group_priority` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `task_group_id`;
-alter table t_ds_task_definition add `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `resource_ids`;
-alter table t_ds_task_definition add `task_group_priority` int(11) DEFAULT '0' COMMENT 'task group id' AFTER `task_group_id`;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_log_col_task_group_id;
+DROP PROCEDURE add_t_ds_task_definition_log_col_task_group_id;
+
+-- alter table t_ds_task_definition_log add `task_group_id` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `resource_ids`;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_col_task_group_id;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_col_task_group_id()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_definition'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='task_group_id')
+ THEN
+alter table t_ds_task_definition add `task_group_id` int DEFAULT NULL COMMENT 'task group id';
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_col_task_group_id;
+DROP PROCEDURE add_t_ds_task_definition_col_task_group_id;
+
+-- alter table t_ds_task_definition_log add `task_group_priority` int(11) DEFAULT NULL COMMENT 'task group id' AFTER `task_group_id`;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_log_col_task_group_priority;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_log_col_task_group_priority()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_definition_log'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='task_group_priority')
+ THEN
+alter table t_ds_task_definition_log add `task_group_priority` tinyint DEFAULT '0' COMMENT 'task group priority' AFTER `task_group_id`;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_log_col_task_group_priority;
+DROP PROCEDURE add_t_ds_task_definition_log_col_task_group_priority;
+-- alter table t_ds_task_definition add `task_group_priority` int(11) DEFAULT '0' COMMENT 'task group id' AFTER `task_group_id`;
+drop PROCEDURE if EXISTS add_t_ds_task_definition_col_task_group_priority;
+delimiter d//
+CREATE PROCEDURE add_t_ds_task_definition_col_task_group_priority()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_task_definition'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='task_group_priority')
+ THEN
+alter table t_ds_task_definition add `task_group_priority` tinyint DEFAULT '0' COMMENT 'task group priority' AFTER `task_group_id`;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_task_definition_col_task_group_priority;
+DROP PROCEDURE add_t_ds_task_definition_col_task_group_priority;
+
+-- ALTER TABLE `t_ds_user` ADD COLUMN `time_zone` varchar(32) DEFAULT NULL COMMENT 'time zone';
+drop PROCEDURE if EXISTS add_t_ds_user_col_time_zone;
+delimiter d//
+CREATE PROCEDURE add_t_ds_user_col_time_zone()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_user'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='t_ds_user')
+ THEN
ALTER TABLE `t_ds_user` ADD COLUMN `time_zone` varchar(32) DEFAULT NULL COMMENT 'time zone';
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_user_col_time_zone;
+DROP PROCEDURE add_t_ds_user_col_time_zone;
+
+-- ALTER TABLE `t_ds_alert` ADD COLUMN `warning_type` tinyint(4) DEFAULT '2' COMMENT '1 process is successfully, 2 process/task is failed';
+drop PROCEDURE if EXISTS add_t_ds_alert_col_warning_type;
+delimiter d//
+CREATE PROCEDURE add_t_ds_alert_col_warning_type()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_alert'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='warning_type')
+ THEN
ALTER TABLE `t_ds_alert` ADD COLUMN `warning_type` tinyint(4) DEFAULT '2' COMMENT '1 process is successfully, 2 process/task is failed';
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_alert_col_warning_type;
+DROP PROCEDURE add_t_ds_alert_col_warning_type;
+-- ALTER TABLE `t_ds_alert` ADD INDEX `idx_status` (`alert_status`) USING BTREE;
+drop PROCEDURE if EXISTS add_t_ds_alert_idx_idx_status;
+delimiter d//
+CREATE PROCEDURE add_t_ds_alert_idx_idx_status()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS
+ WHERE TABLE_NAME='t_ds_alert'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND INDEX_NAME='idx_status')
+ THEN
ALTER TABLE `t_ds_alert` ADD INDEX `idx_status` (`alert_status`) USING BTREE;
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_alert_idx_idx_status;
+DROP PROCEDURE add_t_ds_alert_idx_idx_status;
+
+-- ALTER TABLE `t_ds_alert` ADD COLUMN `project_code` bigint DEFAULT NULL COMMENT 'project_code';
+-- ALTER TABLE `t_ds_alert` ADD COLUMN `process_definition_code` bigint DEFAULT NULL COMMENT 'process_definition_code';
+-- ALTER TABLE `t_ds_alert` ADD COLUMN `process_instance_id` int DEFAULT NULL COMMENT 'process_instance_id';
+-- ALTER TABLE `t_ds_alert` ADD COLUMN `alert_type` int DEFAULT NULL COMMENT 'alert_type';
+drop PROCEDURE if EXISTS add_t_ds_alert_col_project_code;
+delimiter d//
+CREATE PROCEDURE add_t_ds_alert_col_project_code()
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME='t_ds_alert'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME='project_code')
+ THEN
+ALTER TABLE `t_ds_alert` ADD COLUMN `project_code` bigint DEFAULT NULL COMMENT 'project_code';
+ALTER TABLE `t_ds_alert` ADD COLUMN `process_definition_code` bigint DEFAULT NULL COMMENT 'process_definition_code';
+ALTER TABLE `t_ds_alert` ADD COLUMN `process_instance_id` int DEFAULT NULL COMMENT 'process_instance_id';
+ALTER TABLE `t_ds_alert` ADD COLUMN `alert_type` int DEFAULT NULL COMMENT 'alert_type';
+END IF;
+END;
+d//
+delimiter ;
+CALL add_t_ds_alert_col_project_code;
+DROP PROCEDURE add_t_ds_alert_col_project_code;
--
-- Table structure for table `t_ds_dq_comparison_type`
@@ -282,6 +666,71 @@ CREATE TABLE `t_ds_relation_namespace_user` (
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`),
- KEY `user_id_index` (`user_id`),
UNIQUE KEY `namespace_user_unique` (`user_id`,`namespace_id`)
-) ENGINE=InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET= utf8;
\ No newline at end of file
+) ENGINE=InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET= utf8;
+
+-- ----------------------------
+-- Table structure for t_ds_alert_send_status
+-- ----------------------------
+DROP TABLE IF EXISTS t_ds_alert_send_status;
+CREATE TABLE t_ds_alert_send_status (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `alert_id` int(11) NOT NULL,
+ `alert_plugin_instance_id` int(11) NOT NULL,
+ `send_status` tinyint(4) DEFAULT '0',
+ `log` text,
+ `create_time` datetime DEFAULT NULL COMMENT 'create time',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `alert_send_status_unique` (`alert_id`,`alert_plugin_instance_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for t_ds_audit_log
+-- ----------------------------
+DROP TABLE IF EXISTS `t_ds_audit_log`;
+CREATE TABLE `t_ds_audit_log` (
+ `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT'key',
+ `user_id` int(11) NOT NULL COMMENT 'user id',
+ `resource_type` int(11) NOT NULL COMMENT 'resource type',
+ `operation` int(11) NOT NULL COMMENT 'operation',
+ `time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
+ `resource_id` int(11) NULL DEFAULT NULL COMMENT 'resource id',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for t_ds_task_group
+-- ----------------------------
+DROP TABLE IF EXISTS `t_ds_task_group`;
+CREATE TABLE `t_ds_task_group` (
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT'key',
+ `name` varchar(100) DEFAULT NULL COMMENT 'task_group name',
+ `description` varchar(200) DEFAULT NULL,
+ `group_size` int (11) NOT NULL COMMENT'group size',
+ `use_size` int (11) DEFAULT '0' COMMENT 'used size',
+ `user_id` int(11) DEFAULT NULL COMMENT 'creator id',
+ `project_code` bigint(20) DEFAULT 0 COMMENT 'project code',
+ `status` tinyint(4) DEFAULT '1' COMMENT '0 not available, 1 available',
+ `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY(`id`)
+) ENGINE= INNODB AUTO_INCREMENT= 1 DEFAULT CHARSET= utf8;
+
+-- ----------------------------
+-- Table structure for t_ds_task_group_queue
+-- ----------------------------
+DROP TABLE IF EXISTS `t_ds_task_group_queue`;
+CREATE TABLE `t_ds_task_group_queue` (
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT'key',
+ `task_id` int(11) DEFAULT NULL COMMENT 'taskintanceid',
+ `task_name` varchar(100) DEFAULT NULL COMMENT 'TaskInstance name',
+ `group_id` int(11) DEFAULT NULL COMMENT 'taskGroup id',
+ `process_id` int(11) DEFAULT NULL COMMENT 'processInstace id',
+ `priority` int(8) DEFAULT '0' COMMENT 'priority',
+ `status` tinyint(4) DEFAULT '-1' COMMENT '-1: waiting 1: running 2: finished',
+ `force_start` tinyint(4) DEFAULT '0' COMMENT 'is force start 0 NO ,1 YES',
+ `in_queue` tinyint(4) DEFAULT '0' COMMENT 'ready to get the queue by other task finish 0 NO ,1 YES',
+ `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY( `id` )
+)ENGINE= INNODB AUTO_INCREMENT= 1 DEFAULT CHARSET= utf8;
\ No newline at end of file
diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql
index 83e1f6eb26..fa0d864f08 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql
@@ -15,101 +15,70 @@
* limitations under the License.
*/
-delimiter d//
-CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
- )
- RETURNS character varying
- LANGUAGE 'plpgsql'
- COST 100
- VOLATILE PARALLEL UNSAFE
-AS $BODY$
-DECLARE
-v_schema varchar;
-BEGIN
- ---get schema name
- v_schema =current_schema();
-
- --- alter column
-EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_resources ALTER COLUMN full_name Type varchar(128)';
-
---- add column
-EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_alert ADD COLUMN IF NOT EXISTS sign varchar(40) NOT NULL DEFAULT '''' ';
-EXECUTE 'comment on column ' || quote_ident(v_schema) ||'.t_ds_alert.sign is ''sign=sha1(content)''';
-
-return 'Success!';
-exception when others then
- ---Raise EXCEPTION '(%)',SQLERRM;
- return SQLERRM;
-END;
-$BODY$;
-
-select dolphin_update_metadata();
-
-d//
-
--- add unique key to t_ds_relation_project_user
-CREATE UNIQUE INDEX t_ds_relation_project_user_un
- on t_ds_relation_project_user (user_id, project_id);
-
--- add unique key to t_ds_project
-CREATE UNIQUE INDEX unique_name on t_ds_project (name);
-CREATE UNIQUE INDEX unique_code on t_ds_project (code);
-
--- add unique key to t_ds_queue
-CREATE UNIQUE INDEX unique_queue_name on t_ds_queue (queue_name);
-
--- add unique key to t_ds_udfs
-CREATE UNIQUE INDEX unique_func_name on t_ds_udfs (func_name);
-
--- add unique key to t_ds_tenant
-CREATE UNIQUE INDEX unique_tenant_code on t_ds_tenant (tenant_code);
-
-delimiter d//
-CREATE OR REPLACE FUNCTION public.dolphin_update_metadata(
- )
- RETURNS character varying
- LANGUAGE 'plpgsql'
- COST 100
- VOLATILE PARALLEL UNSAFE
-AS $BODY$
-DECLARE
-v_schema varchar;
-BEGIN
- ---get schema name
- v_schema =current_schema();
-
-EXECUTE 'DROP INDEX IF EXISTS "process_task_relation_idx_project_code_process_definition_code"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS process_task_relation_idx_project_code_process_definition_code ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation USING Btree("project_code","process_definition_code")';
-
-EXECUTE 'DROP INDEX IF EXISTS "process_task_relation_idx_pre_task_code_version"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS process_task_relation_idx_pre_task_code_version ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation USING Btree("pre_task_code","pre_task_version")';
-
-EXECUTE 'DROP INDEX IF EXISTS "process_task_relation_idx_post_task_code_version"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS process_task_relation_idx_post_task_code_version ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation USING Btree("post_task_code","post_task_version")';
-
-EXECUTE 'DROP INDEX IF EXISTS "process_task_relation_log_idx_project_code_process_definition_code"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS process_task_relation_log_idx_project_code_process_definition_code ON ' || quote_ident(v_schema) ||'.t_ds_process_task_relation_log USING Btree("project_code","process_definition_code")';
-
-EXECUTE 'DROP INDEX IF EXISTS "idx_task_definition_log_code_version"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS idx_task_definition_log_code_version ON ' || quote_ident(v_schema) ||'.t_ds_task_definition_log USING Btree("code","version")';
-
-EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_user ADD COLUMN IF NOT EXISTS "time_zone" varchar(32) DEFAULT NULL';
-
-EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_alert ADD COLUMN IF NOT EXISTS "warning_type" int DEFAULT 2';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_comparison_type" (
- id serial NOT NULL,
- "type" varchar NOT NULL,
- execute_sql varchar NULL,
- output_table varchar NULL,
- "name" varchar NULL,
- create_time timestamp NULL,
- update_time timestamp NULL,
- is_inner_source bool NULL,
- CONSTRAINT t_ds_dq_comparison_type_pk PRIMARY KEY (id)
- )';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_execute_result" (
+--- Drop table: Some table forget delete in the past, should be delete in version 1.2.0
+DROP TABLE IF EXISTS t_ds_worker_server;
+
+--- Add CONSTRAINT key
+ALTER TABLE t_ds_task_instance DROP CONSTRAINT IF EXISTS foreign_key_instance_id;
+ALTER TABLE t_ds_task_instance ADD CONSTRAINT foreign_key_instance_id FOREIGN KEY(process_instance_id) REFERENCES t_ds_process_instance(id) ON DELETE CASCADE;
+
+--- Add column
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS sign varchar(40) NOT NULL DEFAULT '';
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS "warning_type" int DEFAULT 2;
+ALTER TABLE t_ds_user ADD COLUMN IF NOT EXISTS "time_zone" varchar(32) DEFAULT NULL;
+ALTER TABLE t_ds_task_instance ADD COLUMN IF NOT EXISTS "task_group_id" int DEFAULT NULL;
+ALTER TABLE t_ds_task_definition ADD COLUMN IF NOT EXISTS "task_group_id" int DEFAULT NULL;
+ALTER TABLE t_ds_task_definition ADD COLUMN IF NOT EXISTS "task_group_priority" int DEFAULT '0';
+ALTER TABLE t_ds_task_definition_log ADD COLUMN IF NOT EXISTS "task_group_id" int DEFAULT NULL;
+ALTER TABLE t_ds_task_definition_log ADD COLUMN IF NOT EXISTS "task_group_priority" int DEFAULT '0';
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS "project_code" bigint DEFAULT NULL;
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS "process_definition_code" bigint DEFAULT NULL;
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS "process_instance_id" int DEFAULT NULL;
+ALTER TABLE t_ds_alert ADD COLUMN IF NOT EXISTS "alert_type" int DEFAULT NULL;
+
+--- Add unique key
+CREATE UNIQUE INDEX IF NOT EXISTS t_ds_relation_project_user_un on t_ds_relation_project_user (user_id, project_id);
+CREATE UNIQUE INDEX IF NOT EXISTS unique_name on t_ds_project (name);
+CREATE UNIQUE INDEX IF NOT EXISTS unique_code on t_ds_project (code);
+CREATE UNIQUE INDEX IF NOT EXISTS unique_queue_name on t_ds_queue (queue_name);
+CREATE UNIQUE INDEX IF NOT EXISTS unique_func_name on t_ds_udfs (func_name);
+CREATE UNIQUE INDEX IF NOT EXISTS unique_tenant_code on t_ds_tenant (tenant_code);
+
+--- Create index
+DROP INDEX IF EXISTS "idx_task_definition_log_project_code";
+CREATE INDEX IF NOT EXISTS idx_task_definition_log_project_code ON t_ds_task_definition_log USING Btree("project_code");
+DROP INDEX IF EXISTS "idx_task_instance_code_version";
+CREATE INDEX IF NOT EXISTS idx_task_instance_code_version ON t_ds_task_instance USING Btree("task_code","task_definition_version");
+DROP INDEX IF EXISTS "idx_status";
+CREATE INDEX IF NOT EXISTS idx_status ON t_ds_alert USING Btree("alert_status");
+DROP INDEX IF EXISTS "idx_sign";
+CREATE INDEX IF NOT EXISTS idx_sign ON t_ds_alert USING Btree("sign");
+DROP INDEX IF EXISTS "process_task_relation_idx_project_code_process_definition_code";
+CREATE INDEX IF NOT EXISTS process_task_relation_idx_project_code_process_definition_code ON t_ds_process_task_relation USING Btree("project_code","process_definition_code");
+DROP INDEX IF EXISTS "process_task_relation_idx_pre_task_code_version";
+CREATE INDEX IF NOT EXISTS process_task_relation_idx_pre_task_code_version ON t_ds_process_task_relation USING Btree("pre_task_code","pre_task_version");
+DROP INDEX IF EXISTS "process_task_relation_idx_post_task_code_version";
+CREATE INDEX IF NOT EXISTS process_task_relation_idx_post_task_code_version ON t_ds_process_task_relation USING Btree("post_task_code","post_task_version");
+DROP INDEX IF EXISTS "process_task_relation_log_idx_project_code_process_definition_code";
+CREATE INDEX IF NOT EXISTS process_task_relation_log_idx_project_code_process_definition_code ON t_ds_process_task_relation_log USING Btree("project_code","process_definition_code");
+DROP INDEX IF EXISTS "idx_task_definition_log_code_version";
+CREATE INDEX IF NOT EXISTS idx_task_definition_log_code_version ON t_ds_task_definition_log USING Btree("code","version");
+DROP INDEX IF EXISTS "user_id_index";
+CREATE INDEX IF NOT EXISTS user_id_index ON t_ds_project USING Btree("user_id");
+
+--- Create table
+CREATE TABLE IF NOT EXISTS "t_ds_dq_comparison_type" (
+ id serial NOT NULL,
+ "type" varchar NOT NULL,
+ execute_sql varchar NULL,
+ output_table varchar NULL,
+ "name" varchar NULL,
+ create_time timestamp NULL,
+ update_time timestamp NULL,
+ is_inner_source bool NULL,
+ CONSTRAINT t_ds_dq_comparison_type_pk PRIMARY KEY (id)
+);
+CREATE TABLE IF NOT EXISTS "t_ds_dq_execute_result" (
id serial NOT NULL,
process_definition_id int4 NULL,
process_instance_id int4 NULL,
@@ -129,9 +98,8 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_execu
comparison_type int4 NULL,
error_output_path text NULL,
CONSTRAINT t_ds_dq_execute_result_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_dq_rule" (
id serial NOT NULL,
"name" varchar(100) DEFAULT NULL,
"type" int4 NULL,
@@ -139,9 +107,8 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule"
create_time timestamp NULL,
update_time timestamp NULL,
CONSTRAINT t_ds_dq_rule_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule_execute_sql" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_dq_rule_execute_sql" (
id serial NOT NULL,
"index" int4 NULL,
"sql" text NULL,
@@ -151,9 +118,8 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule_
update_time timestamp NULL,
is_error_output_sql bool NULL,
CONSTRAINT t_ds_dq_rule_execute_sql_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule_input_entry" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_dq_rule_input_entry" (
id serial NOT NULL,
field varchar(255) DEFAULT NULL,
"type" varchar(255) DEFAULT NULL,
@@ -164,16 +130,15 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_rule_
option_source_type int4 NULL,
value_type int4 NULL,
input_type int4 NULL,
- is_show int2 NULL DEFAULT "1"::smallint,
- can_edit int2 NULL DEFAULT "1"::smallint,
- is_emit int2 NULL DEFAULT "0"::smallint,
- is_validate int2 NULL DEFAULT "0"::smallint,
+ is_show int2 NULL DEFAULT '1'::smallint,
+ can_edit int2 NULL DEFAULT '1'::smallint,
+ is_emit int2 NULL DEFAULT '0'::smallint,
+ is_validate int2 NULL DEFAULT '0'::smallint,
create_time timestamp NULL,
update_time timestamp NULL,
CONSTRAINT t_ds_dq_rule_input_entry_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_task_statistics_value" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_dq_task_statistics_value" (
id serial NOT NULL,
process_definition_id int4 NOT NULL,
task_instance_id int4 NULL,
@@ -185,18 +150,16 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_dq_task_
create_time timestamp(0) NULL,
update_time timestamp(0) NULL,
CONSTRAINT t_ds_dq_task_statistics_value_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_relation_rule_execute_sql" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_relation_rule_execute_sql" (
id serial NOT NULL,
rule_id int4 NULL,
execute_sql_id int4 NULL,
create_time timestamp NULL,
update_time timestamp NULL,
CONSTRAINT t_ds_relation_rule_execute_sql_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_relation_rule_input_entry" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_relation_rule_input_entry" (
id serial NOT NULL,
rule_id int4 NULL,
rule_input_entry_id int4 NULL,
@@ -205,31 +168,20 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS' || quote_ident(v_schema) ||'."t_ds_relation
create_time timestamp NULL,
update_time timestamp NULL,
CONSTRAINT t_ds_relation_rule_input_entry_pk PRIMARY KEY (id)
-)';
-
-EXECUTE 'DROP INDEX IF EXISTS "idx_alert_status"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS idx_alert_status ON ' || quote_ident(v_schema) ||'.t_ds_alert USING Btree("alert_status")';
-
-EXECUTE 'DROP INDEX IF EXISTS "idx_task_definition_log_project_code"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS idx_task_definition_log_project_code ON ' || quote_ident(v_schema) ||'.t_ds_task_definition_log USING Btree("project_code")';
-
-EXECUTE 'DROP INDEX IF EXISTS "idx_task_instance_code_version"';
-EXECUTE 'CREATE INDEX IF NOT EXISTS idx_task_instance_code_version ON' || quote_ident(v_schema) ||'.t_ds_task_instance USING Btree("task_code","task_definition_version")';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS '|| quote_ident(v_schema) ||'."t_ds_k8s" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_k8s" (
id serial NOT NULL,
k8s_name VARCHAR(100) DEFAULT NULL ,
k8s_config text ,
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS '|| quote_ident(v_schema) ||'."t_ds_k8s_namespace" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_k8s_namespace" (
id serial NOT NULL,
limits_memory int DEFAULT NULL ,
namespace varchar(100) DEFAULT NULL ,
- online_job_num int DEFAULT NULL,
+ online_job_num int DEFAULT '0',
user_id int DEFAULT NULL,
pod_replicas int DEFAULT NULL,
pod_request_cpu NUMERIC(13,4) NULL,
@@ -240,9 +192,8 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS '|| quote_ident(v_schema) ||'."t_ds_k8s_name
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id) ,
CONSTRAINT k8s_namespace_unique UNIQUE (namespace,k8s)
-)';
-
-EXECUTE 'CREATE TABLE IF NOT EXISTS '|| quote_ident(v_schema) ||'."t_ds_relation_namespace_user" (
+);
+CREATE TABLE IF NOT EXISTS "t_ds_relation_namespace_user" (
id serial NOT NULL,
user_id int DEFAULT NULL ,
namespace_id int DEFAULT NULL ,
@@ -251,15 +202,50 @@ EXECUTE 'CREATE TABLE IF NOT EXISTS '|| quote_ident(v_schema) ||'."t_ds_relation
update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id) ,
CONSTRAINT namespace_user_unique UNIQUE (user_id,namespace_id)
-)';
-
-return 'Success!';
-exception when others then
- ---Raise EXCEPTION '(%)',SQLERRM;
- return SQLERRM;
-END;
-$BODY$;
-
-select dolphin_update_metadata();
-
-d//
+);
+CREATE TABLE IF NOT EXISTS "t_ds_alert_send_status" (
+ id serial NOT NULL,
+ alert_id int NOT NULL,
+ alert_plugin_instance_id int NOT NULL,
+ send_status int DEFAULT '0',
+ log text,
+ create_time timestamp DEFAULT NULL,
+ PRIMARY KEY (id),
+ CONSTRAINT alert_send_status_unique UNIQUE (alert_id,alert_plugin_instance_id)
+);
+CREATE TABLE IF NOT EXISTS "t_ds_audit_log" (
+ id serial NOT NULL,
+ user_id int NOT NULL,
+ resource_type int NOT NULL,
+ operation int NOT NULL,
+ time timestamp DEFAULT NULL ,
+ resource_id int NOT NULL,
+ PRIMARY KEY (id)
+);
+CREATE TABLE IF NOT EXISTS "t_ds_task_group" (
+ id serial NOT NULL,
+ name varchar(100) DEFAULT NULL ,
+ description varchar(200) DEFAULT NULL ,
+ group_size int NOT NULL ,
+ project_code bigint DEFAULT '0',
+ use_size int DEFAULT '0' ,
+ user_id int DEFAULT NULL ,
+ status int DEFAULT '1' ,
+ create_time timestamp DEFAULT NULL ,
+ update_time timestamp DEFAULT NULL ,
+ PRIMARY KEY(id)
+);
+CREATE TABLE IF NOT EXISTS "t_ds_task_group_queue" (
+ id serial NOT NULL,
+ task_id int DEFAULT NULL ,
+ task_name VARCHAR(100) DEFAULT NULL ,
+ group_id int DEFAULT NULL ,
+ process_id int DEFAULT NULL ,
+ priority int DEFAULT '0' ,
+ status int DEFAULT '-1' ,
+ force_start int DEFAULT '0' ,
+ in_queue int DEFAULT '0' ,
+ create_time timestamp DEFAULT NULL ,
+ update_time timestamp DEFAULT NULL ,
+ PRIMARY KEY (id)
+);