mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-03 20:58:11 +08:00
fix schema 1.4.0 (#4564)
This commit is contained in:
parent
8be894cb88
commit
891df6d5e2
@ -16,6 +16,10 @@
|
||||
*/
|
||||
|
||||
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_ds_plugin_define
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `t_ds_plugin_define`;
|
||||
CREATE TABLE `t_ds_plugin_define` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
@ -28,6 +32,13 @@ CREATE TABLE `t_ds_plugin_define` (
|
||||
UNIQUE KEY `t_ds_plugin_define_UN` (`plugin_name`,`plugin_type`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of t_ds_plugin_define
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_ds_alert_plugin_instance
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `t_ds_alert_plugin_instance`;
|
||||
CREATE TABLE `t_ds_alert_plugin_instance` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
@ -39,31 +50,101 @@ CREATE TABLE `t_ds_alert_plugin_instance` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE t_ds_process_definition
|
||||
ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
-- ----------------------------
|
||||
-- Records of t_ds_alert_plugin_instance
|
||||
-- ----------------------------
|
||||
|
||||
ALTER TABLE t_ds_process_definition_version
|
||||
ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
-- uc_dolphin_T_t_ds_process_definition_A_warning_group_id
|
||||
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_warning_group_id;
|
||||
delimiter d//
|
||||
CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_warning_group_id()
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_process_definition'
|
||||
AND TABLE_SCHEMA=(SELECT DATABASE())
|
||||
AND COLUMN_NAME ='warning_group_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_process_definition ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
ALTER TABLE t_ds_alertgroup
|
||||
ADD COLUMN `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids' AFTER `id`,
|
||||
ADD COLUMN `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id' AFTER `alert_instance_ids`;
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
CALL uc_dolphin_T_t_ds_process_definition_A_warning_group_id();
|
||||
DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_warning_group_id;
|
||||
|
||||
-- uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id
|
||||
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id;
|
||||
delimiter d//
|
||||
CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id()
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_process_definition_version'
|
||||
AND TABLE_SCHEMA=(SELECT DATABASE())
|
||||
AND COLUMN_NAME ='warning_group_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_process_definition_version ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
CALL uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id();
|
||||
DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id;
|
||||
|
||||
-- uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids
|
||||
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids;
|
||||
delimiter d//
|
||||
CREATE PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids()
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_alertgroup'
|
||||
AND TABLE_SCHEMA=(SELECT DATABASE())
|
||||
AND COLUMN_NAME ='alert_instance_ids')
|
||||
THEN
|
||||
ALTER TABLE t_ds_alertgroup ADD COLUMN `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids' AFTER `id`;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
CALL uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids();
|
||||
DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids;
|
||||
|
||||
-- uc_dolphin_T_t_ds_alertgroup_A_create_user_id
|
||||
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alertgroup_A_create_user_id;
|
||||
delimiter d//
|
||||
CREATE PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_create_user_id()
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_alertgroup'
|
||||
AND TABLE_SCHEMA=(SELECT DATABASE())
|
||||
AND COLUMN_NAME ='create_user_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_alertgroup ADD COLUMN `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id' AFTER `alert_instance_ids`;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
CALL uc_dolphin_T_t_ds_alertgroup_A_create_user_id();
|
||||
DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_create_user_id;
|
||||
|
||||
-- ----------------------------
|
||||
-- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
|
||||
-- ----------------------------
|
||||
/*
|
||||
ALTER TABLE t_ds_process_definition DROP receivers, DROP receivers_cc;
|
||||
|
||||
ALTER TABLE t_ds_process_definition_version DROP receivers, DROP receivers_cc;
|
||||
-- ALTER TABLE t_ds_process_definition DROP receivers, DROP receivers_cc;
|
||||
|
||||
ALTER TABLE t_ds_alert DROP show_type,DROP alert_type,DROP receivers,DROP receivers_cc;
|
||||
-- ALTER TABLE t_ds_process_definition_version DROP receivers, DROP receivers_cc;
|
||||
|
||||
ALTER TABLE t_ds_alertgroup DROP group_type;
|
||||
|
||||
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
|
||||
*/
|
||||
-- ALTER TABLE t_ds_alert DROP show_type,DROP alert_type,DROP receivers,DROP receivers_cc;
|
||||
|
||||
-- ALTER TABLE t_ds_alertgroup DROP group_type;
|
||||
|
||||
-- DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_ds_plugin_define
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS t_ds_plugin_define;
|
||||
CREATE TABLE t_ds_plugin_define (
|
||||
id serial NOT NULL,
|
||||
@ -26,7 +30,9 @@ CREATE TABLE t_ds_plugin_define (
|
||||
CONSTRAINT t_ds_plugin_define_un UNIQUE (plugin_name, plugin_type)
|
||||
);
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_ds_alert_plugin_instance
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS t_ds_alert_plugin_instance;
|
||||
CREATE TABLE t_ds_alert_plugin_instance (
|
||||
id serial NOT NULL,
|
||||
@ -38,28 +44,88 @@ CREATE TABLE t_ds_alert_plugin_instance (
|
||||
CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE t_ds_process_definition
|
||||
ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
-- uc_dolphin_T_t_ds_process_definition_A_warning_group_id
|
||||
delimiter d//
|
||||
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_definition_A_warning_group_id() RETURNS void AS $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_process_definition'
|
||||
AND COLUMN_NAME ='warning_group_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_process_definition ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
d//
|
||||
|
||||
ALTER TABLE t_ds_process_definition_version
|
||||
ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
delimiter ;
|
||||
SELECT uc_dolphin_T_t_ds_process_definition_A_warning_group_id();
|
||||
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_warning_group_id();
|
||||
|
||||
ALTER TABLE t_ds_alertgroup
|
||||
ADD COLUMN `alert_instance_ids` int4 DEFAULT NULL COMMENT 'alert instance ids' AFTER `id`;
|
||||
ADD COLUMN `create_user_id` varchar(255) DEFAULT NULL COMMENT 'create user id' AFTER `alert_instance_ids`,
|
||||
-- uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id
|
||||
delimiter d//
|
||||
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id() RETURNS void AS $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_process_definition_version'
|
||||
AND COLUMN_NAME ='warning_group_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_process_definition_version ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
SELECT uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id();
|
||||
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id();
|
||||
|
||||
-- uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids
|
||||
delimiter d//
|
||||
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids() RETURNS void AS $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_alertgroup'
|
||||
AND COLUMN_NAME ='alert_instance_ids')
|
||||
THEN
|
||||
ALTER TABLE t_ds_alertgroup ADD COLUMN `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids' AFTER `id`;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
SELECT uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids();
|
||||
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids();
|
||||
|
||||
-- uc_dolphin_T_t_ds_alertgroup_A_create_user_id
|
||||
delimiter d//
|
||||
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_alertgroup_A_create_user_id() RETURNS void AS $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_NAME='t_ds_alertgroup'
|
||||
AND COLUMN_NAME ='create_user_id')
|
||||
THEN
|
||||
ALTER TABLE t_ds_alertgroup ADD COLUMN `create_user_id` int4 DEFAULT NULL COMMENT 'create user id' AFTER `alert_instance_ids`;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
d//
|
||||
|
||||
delimiter ;
|
||||
SELECT uc_dolphin_T_t_ds_alertgroup_A_create_user_id();
|
||||
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_alertgroup_A_create_user_id();
|
||||
|
||||
-- ----------------------------
|
||||
-- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
|
||||
-- ----------------------------
|
||||
/*
|
||||
ALTER TABLE t_ds_process_definition DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
|
||||
|
||||
ALTER TABLE t_ds_process_definition_version DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
|
||||
-- ALTER TABLE t_ds_process_definition DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
|
||||
|
||||
ALTER TABLE t_ds_alert DROP COLUMN "show_type",DROP COLUMN "alert_type",DROP COLUMN "receivers",DROP COLUMN "receivers_cc";
|
||||
-- ALTER TABLE t_ds_process_definition_version DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
|
||||
|
||||
ALTER TABLE t_ds_alertgroup DROP COLUMN "group_type";
|
||||
-- ALTER TABLE t_ds_alert DROP COLUMN "show_type",DROP COLUMN "alert_type",DROP COLUMN "receivers",DROP COLUMN "receivers_cc";
|
||||
|
||||
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
|
||||
*/
|
||||
-- ALTER TABLE t_ds_alertgroup DROP COLUMN "group_type";
|
||||
|
||||
-- DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
|
||||
|
Loading…
Reference in New Issue
Block a user