Browse Source

Merge pull request #2671 from simon824/dev-1.3.0

add unique key for t_ds_process_definition
pull/3/MERGE
xingchun-chen 5 years ago committed by GitHub
parent
commit
96a4befa1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      sql/dolphinscheduler-postgre.sql
  2. 20
      sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql
  3. 19
      sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql

3
sql/dolphinscheduler-postgre.sql

@ -309,7 +309,8 @@ CREATE TABLE t_ds_process_definition (
update_time timestamp DEFAULT NULL , update_time timestamp DEFAULT NULL ,
modify_by varchar(36) DEFAULT '' , modify_by varchar(36) DEFAULT '' ,
resource_ids varchar(64), resource_ids varchar(64),
PRIMARY KEY (id) PRIMARY KEY (id),
CONSTRAINT process_definition_unique UNIQUE (name, project_id)
) ; ) ;
create index process_definition_index on t_ds_process_definition (project_id,id); create index process_definition_index on t_ds_process_definition (project_id,id);

20
sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql

@ -357,3 +357,23 @@ delimiter ;
CALL dc_dolphin_T_t_ds_error_command_D_worker_group_id; CALL dc_dolphin_T_t_ds_error_command_D_worker_group_id;
DROP PROCEDURE dc_dolphin_T_t_ds_error_command_D_worker_group_id; DROP PROCEDURE dc_dolphin_T_t_ds_error_command_D_worker_group_id;
-- uc_dolphin_T_t_ds_process_definition_A_process_definition_unique
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_process_definition_unique;
delimiter d//
CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_modify_by()
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_NAME='t_ds_process_definition'
AND TABLE_SCHEMA=(SELECT DATABASE())
AND INDEX_NAME ='process_definition_unique')
THEN
ALTER TABLE t_ds_process_definition ADD UNIQUE KEY `process_definition_unique` (`name`,`project_id`);
END IF;
END;
d//
delimiter ;
CALL uc_dolphin_T_t_ds_process_definition_A_process_definition_unique;
DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_process_definition_unique;

19
sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql

@ -364,3 +364,22 @@ select dc_dolphin_T_t_ds_error_command_D_worker_group_id();
DROP FUNCTION dc_dolphin_T_t_ds_error_command_D_worker_group_id(); DROP FUNCTION dc_dolphin_T_t_ds_error_command_D_worker_group_id();
-- uc_dolphin_T_t_ds_process_definition_A_process_definition_unique
delimiter d//
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_definition_A_process_definition_unique() RETURNS void AS $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_NAME='t_ds_process_definition'
AND INDEX_NAME ='process_definition_unique')
THEN
ALTER TABLE t_ds_process_definition ADD CONSTRAINT process_definition_unique UNIQUE (name,project_id);
END IF;
END;
$$ LANGUAGE plpgsql;
d//
delimiter ;
SELECT uc_dolphin_T_t_ds_process_definition_A_process_definition_unique();
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_process_definition_unique();

Loading…
Cancel
Save