mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 04:08:31 +08:00
[Improvement] Resource authority module database table unique index increased. (#10807)
* Resource authority module database table unique index increased. * add unique in sql file * rerun * ut fix * e2e rerun * dao un fix
This commit is contained in:
parent
d4540c489b
commit
7056e1f9fe
@ -634,7 +634,9 @@ CREATE TABLE t_ds_project
|
||||
flag tinyint(4) DEFAULT '1',
|
||||
create_time datetime NOT NULL,
|
||||
update_time datetime DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY unique_name (name),
|
||||
UNIQUE KEY unique_code (code)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
@ -652,7 +654,8 @@ CREATE TABLE t_ds_queue
|
||||
queue varchar(64) DEFAULT NULL,
|
||||
create_time datetime DEFAULT NULL,
|
||||
update_time datetime DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY unique_queue_name (queue_name)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
@ -880,7 +883,8 @@ CREATE TABLE t_ds_tenant
|
||||
queue_id int(11) DEFAULT NULL,
|
||||
create_time datetime DEFAULT NULL,
|
||||
update_time datetime DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY unique_tenant_code (tenant_code)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
@ -905,7 +909,8 @@ CREATE TABLE t_ds_udfs
|
||||
resource_name varchar(255) NOT NULL,
|
||||
create_time datetime NOT NULL,
|
||||
update_time datetime NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY unique_func_name (func_name)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -638,7 +638,9 @@ CREATE TABLE `t_ds_project` (
|
||||
`create_time` datetime NOT NULL COMMENT 'create time',
|
||||
`update_time` datetime DEFAULT NULL COMMENT 'update time',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `user_id_index` (`user_id`) USING BTREE
|
||||
KEY `user_id_index` (`user_id`) USING BTREE,
|
||||
UNIQUE KEY `unique_name`(`name`),
|
||||
UNIQUE KEY `unique_code`(`code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
@ -655,7 +657,8 @@ CREATE TABLE `t_ds_queue` (
|
||||
`queue` varchar(64) DEFAULT NULL COMMENT 'yarn queue name',
|
||||
`create_time` datetime DEFAULT NULL COMMENT 'create time',
|
||||
`update_time` datetime DEFAULT NULL COMMENT 'update time',
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_queue_name`(`queue_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
@ -874,7 +877,8 @@ CREATE TABLE `t_ds_tenant` (
|
||||
`queue_id` int(11) DEFAULT NULL COMMENT 'queue id',
|
||||
`create_time` datetime DEFAULT NULL COMMENT 'create time',
|
||||
`update_time` datetime DEFAULT NULL COMMENT 'update time',
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_tenant_code`(`tenant_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
@ -898,7 +902,8 @@ CREATE TABLE `t_ds_udfs` (
|
||||
`resource_name` varchar(255) NOT NULL COMMENT 'resource name',
|
||||
`create_time` datetime NOT NULL COMMENT 'create time',
|
||||
`update_time` datetime NOT NULL COMMENT 'update time',
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_func_name`(`func_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -567,6 +567,8 @@ CREATE TABLE t_ds_project (
|
||||
) ;
|
||||
|
||||
create index user_id_index on t_ds_project (user_id);
|
||||
CREATE UNIQUE INDEX unique_name on t_ds_project (name);
|
||||
CREATE UNIQUE INDEX unique_code on t_ds_project (code);
|
||||
|
||||
--
|
||||
-- Table structure for table t_ds_queue
|
||||
@ -581,7 +583,8 @@ CREATE TABLE t_ds_queue (
|
||||
update_time timestamp DEFAULT NULL ,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
-- add unique key to t_ds_queue
|
||||
CREATE UNIQUE INDEX unique_queue_name on t_ds_queue (queue_name);
|
||||
|
||||
--
|
||||
-- Table structure for table t_ds_relation_datasource_user
|
||||
@ -597,7 +600,6 @@ CREATE TABLE t_ds_relation_datasource_user (
|
||||
update_time timestamp DEFAULT NULL ,
|
||||
PRIMARY KEY (id)
|
||||
) ;
|
||||
;
|
||||
|
||||
--
|
||||
-- Table structure for table t_ds_relation_process_instance
|
||||
@ -779,6 +781,8 @@ CREATE TABLE t_ds_tenant (
|
||||
update_time timestamp DEFAULT NULL ,
|
||||
PRIMARY KEY (id)
|
||||
) ;
|
||||
-- add unique key to t_ds_tenant
|
||||
CREATE UNIQUE INDEX unique_tenant_code on t_ds_tenant (tenant_code);
|
||||
|
||||
--
|
||||
-- Table structure for table t_ds_udfs
|
||||
@ -800,6 +804,8 @@ CREATE TABLE t_ds_udfs (
|
||||
update_time timestamp NOT NULL ,
|
||||
PRIMARY KEY (id)
|
||||
) ;
|
||||
-- add unique key to t_ds_udfs
|
||||
CREATE UNIQUE INDEX unique_func_name on t_ds_udfs (func_name);
|
||||
|
||||
--
|
||||
-- Table structure for table t_ds_user
|
||||
@ -959,7 +965,6 @@ 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');
|
||||
|
@ -61,6 +61,19 @@ 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);
|
||||
|
||||
-- add unique key to t_ds_project
|
||||
ALTER TABLE t_ds_project ADD UNIQUE KEY unique_name(name);
|
||||
ALTER TABLE t_ds_project ADD UNIQUE KEY unique_code(code);
|
||||
|
||||
-- add unique key to t_ds_queue
|
||||
ALTER TABLE t_ds_queue ADD UNIQUE KEY unique_queue_name(queue_name);
|
||||
|
||||
-- add unique key to t_ds_udfs
|
||||
ALTER TABLE t_ds_udfs ADD UNIQUE KEY unique_func_name(func_name);
|
||||
|
||||
-- add unique key to t_ds_tenant
|
||||
ALTER TABLE t_ds_tenant ADD UNIQUE KEY unique_tenant_code(tenant_code);
|
||||
|
||||
ALTER TABLE `t_ds_task_instance` ADD INDEX `idx_code_version` (`task_code`, `task_definition_version`) USING BTREE;
|
||||
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;
|
||||
|
@ -51,6 +51,19 @@ d//
|
||||
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(
|
||||
)
|
||||
|
@ -53,10 +53,10 @@ public class UdfFuncMapperTest extends BaseDaoTest {
|
||||
*
|
||||
* @return UdfFunc
|
||||
*/
|
||||
private UdfFunc insertOne() {
|
||||
private UdfFunc insertOne(String funcName) {
|
||||
UdfFunc udfFunc = new UdfFunc();
|
||||
udfFunc.setUserId(1);
|
||||
udfFunc.setFuncName("dolphin_udf_func");
|
||||
udfFunc.setFuncName(funcName);
|
||||
udfFunc.setClassName("org.apache.dolphinscheduler.test.mr");
|
||||
udfFunc.setType(UdfType.HIVE);
|
||||
udfFunc.setResourceId(1);
|
||||
@ -75,7 +75,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
|
||||
private UdfFunc insertOne(User user) {
|
||||
UdfFunc udfFunc = new UdfFunc();
|
||||
udfFunc.setUserId(user.getId());
|
||||
udfFunc.setFuncName("dolphin_udf_func");
|
||||
udfFunc.setFuncName("dolphin_udf_func" + user.getUserName());
|
||||
udfFunc.setClassName("org.apache.dolphinscheduler.test.mr");
|
||||
udfFunc.setType(UdfType.HIVE);
|
||||
udfFunc.setResourceId(1);
|
||||
@ -163,7 +163,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
//insertOne
|
||||
UdfFunc udfFunc = insertOne();
|
||||
UdfFunc udfFunc = insertOne("func1");
|
||||
udfFunc.setResourceName("dolphin_resource_update");
|
||||
udfFunc.setResourceId(2);
|
||||
udfFunc.setClassName("org.apache.dolphinscheduler.test.mrUpdate");
|
||||
@ -180,7 +180,7 @@ public class UdfFuncMapperTest extends BaseDaoTest {
|
||||
@Test
|
||||
public void testDelete() {
|
||||
//insertOne
|
||||
UdfFunc udfFunc = insertOne();
|
||||
UdfFunc udfFunc = insertOne("func2");
|
||||
//delete
|
||||
int delete = udfFuncMapper.deleteById(udfFunc.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
@ -192,9 +192,9 @@ public class UdfFuncMapperTest extends BaseDaoTest {
|
||||
@Test
|
||||
public void testQueryUdfByIdStr() {
|
||||
//insertOne
|
||||
UdfFunc udfFunc = insertOne();
|
||||
UdfFunc udfFunc = insertOne("func3");
|
||||
//insertOne
|
||||
UdfFunc udfFunc1 = insertOne();
|
||||
UdfFunc udfFunc1 = insertOne("func4");
|
||||
Integer[] idArray = new Integer[]{udfFunc.getId(), udfFunc1.getId()};
|
||||
//queryUdfByIdStr
|
||||
List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfByIdStr(idArray, "");
|
||||
|
Loading…
Reference in New Issue
Block a user