-- KS-KM自身的SQL，KS-KM依赖 Logi-Job 和 Logi-Security，因此另外两个ddl sql文件也需要执行
DROP TABLE IF EXISTS `ks_kc_connect_cluster`;
CREATE TABLE `ks_kc_connect_cluster` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Connect集群ID',
     `kafka_cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Kafka集群ID',
     `name` varchar(128) NOT NULL DEFAULT '' COMMENT '集群名称',
     `group_name` varchar(128) NOT NULL DEFAULT '' COMMENT '集群Group名称',
     `cluster_url` varchar(1024) NOT NULL DEFAULT '' COMMENT '集群地址',
     `member_leader_url` varchar(1024) NOT NULL DEFAULT '' COMMENT 'URL地址',
     `version` varchar(64) NOT NULL DEFAULT '' COMMENT 'connect版本',
     `jmx_properties` text COMMENT 'JMX配置',
     `state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '集群使用的消费组状态，也表示集群状态:-1 Unknown,0 ReBalance,1 Active,2 Dead,3 Empty',
     `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '接入时间',
     `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uniq_id_group_name` (`id`,`group_name`),
     UNIQUE KEY `uniq_name_kafka_cluster` (`name`,`kafka_cluster_phy_id`),
     KEY `idx_kafka_cluster_phy_id` (`kafka_cluster_phy_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Connect集群信息表';

DROP TABLE IF EXISTS `ks_kc_connector`;
CREATE TABLE `ks_kc_connector` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
     `kafka_cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Kafka集群ID',
     `connect_cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Connect集群ID',
     `connector_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称',
     `connector_class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类',
     `connector_type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型',
     `state` varchar(45) NOT NULL DEFAULT '' COMMENT '状态',
     `topics` text COMMENT '访问过的Topics',
     `task_count` int(11) NOT NULL DEFAULT '0' COMMENT '任务数',
     `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uniq_connect_cluster_id_connector_name` (`connect_cluster_id`,`connector_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Connector信息表';

DROP TABLE IF EXISTS `ks_kc_worker`;
CREATE TABLE `ks_kc_worker` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
     `kafka_cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Kafka集群ID',
     `connect_cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Connect集群ID',
     `member_id` varchar(512) NOT NULL DEFAULT '' COMMENT '成员ID',
     `host` varchar(128) NOT NULL DEFAULT '' COMMENT '主机名',
     `jmx_port` int(16) NOT NULL DEFAULT '-1' COMMENT 'Jmx端口',
     `url` varchar(1024) NOT NULL DEFAULT '' COMMENT 'URL信息',
     `leader_url` varchar(1024) NOT NULL DEFAULT '' COMMENT 'leaderURL信息',
     `leader` int(16) NOT NULL DEFAULT '0' COMMENT '状态: 1是leader，0不是leader',
     `worker_id` varchar(128) NOT NULL COMMENT 'worker地址',
     `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uniq_cluster_id_member_id` (`connect_cluster_id`,`member_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='worker信息表';

DROP TABLE IF EXISTS `ks_kc_worker_connector`;
CREATE TABLE `ks_kc_worker_connector` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
     `kafka_cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Kafka集群ID',
     `connect_cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Connect集群ID',
     `connector_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称',
     `worker_member_id` varchar(256) NOT NULL DEFAULT '',
     `task_id` int(16) NOT NULL DEFAULT '-1' COMMENT 'Task的ID',
     `state` varchar(128) DEFAULT NULL COMMENT '任务状态',
     `worker_id` varchar(128) DEFAULT NULL COMMENT 'worker信息',
     `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
     PRIMARY KEY (`id`),
     UNIQUE KEY `uniq_relation` (`connect_cluster_id`,`connector_name`,`task_id`,`worker_member_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Worker和Connector关系表';

DROP TABLE IF EXISTS `ks_km_zookeeper`;
CREATE TABLE `ks_km_zookeeper` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
    `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID',
    `host` varchar(128) NOT NULL DEFAULT '' COMMENT 'zookeeper主机名',
    `port` int(16) NOT NULL DEFAULT '-1' COMMENT 'zookeeper端口',
    `role` varchar(16) NOT NULL DEFAULT '' COMMENT '角色, leader follower observer',
    `version` varchar(128) NOT NULL DEFAULT '' COMMENT 'zookeeper版本',
    `status` int(16) NOT NULL DEFAULT '0' COMMENT '状态: 1存活，0未存活，11存活但是4字命令使用不了',
    `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uniq_cluster_phy_id_host_port` (`cluster_phy_id`,`host`, `port`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Zookeeper信息表';


DROP TABLE IF EXISTS `ks_km_group`;
CREATE TABLE `ks_km_group` (
     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
     `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群id',
     `name` varchar(192) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group名称',
     `member_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '成员数',
     `topic_members` text CHARACTER SET utf8 COMMENT 'group消费的topic列表',
     `partition_assignor` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '分配策略',
     `coordinator_id` int(11) NOT NULL COMMENT 'group协调器brokerId',
     `type` int(11) NOT NULL COMMENT 'group类型 0：consumer 1：connector',
     `state` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '状态',
     `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uniq_cluster_phy_id_name` (`cluster_phy_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Group信息表';

DROP TABLE IF EXISTS `ks_km_broker`;
CREATE TABLE `ks_km_broker` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID',
  `broker_id` int(16) NOT NULL DEFAULT '-1' COMMENT 'brokerId',
  `host` varchar(128) NOT NULL DEFAULT '' COMMENT 'broker主机名',
  `port` int(16) NOT NULL DEFAULT '-1' COMMENT 'broker端口',
  `jmx_port` int(16) NOT NULL DEFAULT '-1' COMMENT 'Jmx端口',
  `start_timestamp` bigint(20) NOT NULL DEFAULT '-1' COMMENT '启动时间',
  `rack` varchar(128) NOT NULL DEFAULT '' COMMENT 'Rack信息',
  `status` int(16) NOT NULL DEFAULT '0' COMMENT '状态: 1存活，0未存活',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `endpoint_map` varchar(1024)  NOT NULL DEFAULT '' COMMENT '监听信息',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_phy_id_broker_id` (`cluster_phy_id`,`broker_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Broker信息表';



DROP TABLE IF EXISTS `ks_km_broker_config`;
CREATE TABLE `ks_km_broker_config` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `broker_id` int(16) NOT NULL DEFAULT '-1' COMMENT 'brokerId',
  `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名称',
  `config_value` text COMMENT '配置值',
  `diff_type` int(16) NOT NULL DEFAULT '-1' COMMENT '差异类型',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_broker_name` (`cluster_phy_id`,`broker_id`,`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Broker配置信息表';



DROP TABLE IF EXISTS `ks_km_cluster_balance_job`;
CREATE TABLE `ks_km_cluster_balance_job` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `brokers` varchar(1024) NOT NULL DEFAULT '' COMMENT '均衡节点',
  `topic_black_list` varchar(4096) NOT NULL DEFAULT '' COMMENT 'topic黑名单',
  `type` int(16) NOT NULL DEFAULT '0' COMMENT '1:周期均衡，2：立即均衡',
  `balance_interval_json` text COMMENT '均衡区间详情',
  `metric_calculation_period` int(16) NOT NULL DEFAULT '0' COMMENT '指标计算周期，单位分钟',
  `reassignment_json` text COMMENT '迁移脚本',
  `parallel_num` int(16) NOT NULL DEFAULT '0' COMMENT '任务并行数',
  `execution_strategy` int(16) NOT NULL DEFAULT '0' COMMENT '执行策略， 1：优先最大副本，2：优先最小副本',
  `throttle_unit_b` bigint(20) NOT NULL DEFAULT '0' COMMENT '限流值',
  `total_reassign_size` double NOT NULL DEFAULT '0' COMMENT '总迁移大小',
  `total_reassign_replica_num` int(16) NOT NULL DEFAULT '0' COMMENT '总迁移副本数',
  `move_in_topic_list` varchar(4096) NOT NULL DEFAULT '' COMMENT '移入topic',
  `broker_balance_detail` text COMMENT '节点均衡详情',
  `status` int(16) NOT NULL DEFAULT '0' COMMENT '任务状态 1：进行中，2：准备，3，成功，4：失败，5：取消',
  `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人',
  `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务开始时间',
  `finished_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务完成时间',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务修改时间',
  `description` text COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='集群均衡任务';



DROP TABLE IF EXISTS `ks_km_cluster_balance_job_config`;
CREATE TABLE `ks_km_cluster_balance_job_config` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `brokers` varchar(256) NOT NULL DEFAULT '' COMMENT '均衡节点',
  `topic_black_list` varchar(4096) NOT NULL DEFAULT '' COMMENT 'topic黑名单',
  `task_cron` varchar(64) NOT NULL DEFAULT '' COMMENT '任务周期',
  `balance_interval_json` text COMMENT '均衡区间详情',
  `metric_calculation_period` int(16) NOT NULL DEFAULT '0' COMMENT '指标计算周期，单位分钟',
  `reassignment_json` text COMMENT '迁移脚本',
  `parallel_num` int(16) NOT NULL DEFAULT '0' COMMENT '任务并行数',
  `execution_strategy` int(16) NOT NULL DEFAULT '0' COMMENT '执行策略， 1：优先最大副本，2：优先最小副本',
  `throttle_unit_b` bigint(20) NOT NULL DEFAULT '0' COMMENT '限流值',
  `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人',
  `status` int(16) NOT NULL DEFAULT '0' COMMENT '任务状态 0：未开启，1：开启',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='集群均衡任务';



DROP TABLE IF EXISTS `ks_km_cluster_balance_reassign`;
CREATE TABLE `ks_km_cluster_balance_reassign` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `job_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '父任务ID',
  `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称',
  `partition_id` int(11) NOT NULL DEFAULT '-1' COMMENT '分区ID',
  `original_broker_ids` text COMMENT '源BrokerId列表',
  `reassign_broker_ids` text COMMENT '目标BrokerId列表',
  `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务开始时间',
  `finished_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务完成时间',
  `extend_data` text COMMENT '扩展数据',
  `status` int(16) NOT NULL DEFAULT '2' COMMENT '任务状态',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='集群平衡迁移详情';



DROP TABLE IF EXISTS `ks_km_group_member`;
CREATE TABLE `ks_km_group_member` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `topic_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Topic名称',
  `group_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Group名称',
  `kafka_user` varchar(192) NOT NULL DEFAULT '' COMMENT 'Kafka用户',
  `state` varchar(64) NOT NULL DEFAULT '' COMMENT '状态',
  `member_count` int(11) NOT NULL DEFAULT '0' COMMENT '成员数',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_topic_group` (`cluster_phy_id`,`topic_name`,`group_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='GroupMember信息表';



DROP TABLE IF EXISTS `ks_km_health_check_result`;
CREATE TABLE `ks_km_health_check_result` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知，1:Cluster，2:Broker，3:Topic，4:Group)',
  `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '物理集群ID',
  `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称',
  `passed` int(11) NOT NULL DEFAULT '0' COMMENT '检查通过(0:未通过，1:通过)',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`,`config_name`,`cluster_phy_id`,`res_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='健康检查结果';



DROP TABLE IF EXISTS `ks_km_job`;
CREATE TABLE `ks_km_job` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `job_name` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '任务名称',
  `job_type` tinyint(10) NOT NULL COMMENT '任务类型',
  `job_status` tinyint(10) NOT NULL COMMENT '任务状态',
  `job_data` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '任务的详细信息',
  `job_desc` varchar(1024) NOT NULL DEFAULT '' COMMENT '任务描述',
  `cluster_id` int(11) NOT NULL COMMENT 'kafka集群id',
  `target` varchar(8192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '任务执行对象',
  `running_status` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '任务运行详细状态(json), Success：7  Fail：1  Doing：2',
  `creator` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '创建者',
  `plan_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '计划执行时间',
  `start_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '实际执行时间',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `index_cluster_id` (`cluster_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Job信息';



DROP TABLE IF EXISTS `ks_km_kafka_acl`;
CREATE TABLE `ks_km_kafka_acl` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `principal` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Kafka用户',
  `operation` int(11) NOT NULL DEFAULT '0' COMMENT '操作',
  `permission_type` int(11) NOT NULL DEFAULT '0' COMMENT '权限类型(0:未知，1:任意，2:拒绝，3:允许)',
  `host` varchar(192) NOT NULL DEFAULT '127.0.0.1' COMMENT '机器',
  `resource_type` int(11) NOT NULL DEFAULT '0' COMMENT '资源类型(0:未知，1:任意，2:Topic，3:Group，4:Cluster，5:事务，6:Token)',
  `resource_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称',
  `pattern_type` int(11) NOT NULL COMMENT '匹配类型(0:未知，1:任意，2:Match，3:Literal，4:prefixed)',
  `unique_field` varchar(1024) NOT NULL DEFAULT '' COMMENT '唯一字段，由cluster_phy_id等字段组成',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_uniq_field` (`unique_field`),
  KEY `idx_cluster_phy_id_principal_res_name` (`cluster_phy_id`,`principal`,`resource_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ACL信息';



DROP TABLE IF EXISTS `ks_km_kafka_change_record`;
CREATE TABLE `ks_km_kafka_change_record` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `res_type` int(11) NOT NULL DEFAULT '-1' COMMENT '资源类型',
  `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称',
  `operate_type` int(11) NOT NULL DEFAULT '-1' COMMENT '操作类型',
  `operate_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  `unique_field` varchar(1024) NOT NULL DEFAULT '' COMMENT '唯一键字段',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_field` (`unique_field`),
  KEY `idx_cluster_phy_id` (`cluster_phy_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Kafka变更记录表';



DROP TABLE IF EXISTS `ks_km_kafka_controller`;
CREATE TABLE `ks_km_kafka_controller` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群id',
  `broker_id` int(16) NOT NULL DEFAULT '-1' COMMENT 'brokerId',
  `broker_host` varchar(256) NOT NULL DEFAULT '' COMMENT '主机名',
  `broker_rack` varchar(256) NOT NULL DEFAULT '' COMMENT 'BrokerRack信息',
  `timestamp` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'controller变更时间，-1表示未存活',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_broker_timestamp` (`cluster_phy_id`,`broker_id`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='controller记录表';



DROP TABLE IF EXISTS `ks_km_kafka_user`;
CREATE TABLE `ks_km_kafka_user` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '名称',
  `token` varchar(8192) NOT NULL DEFAULT '' COMMENT '密钥',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_phy_id_name` (`cluster_phy_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Kafka-User信息表';



DROP TABLE IF EXISTS `ks_km_partition`;
CREATE TABLE `ks_km_partition` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称',
  `partition_id` int(11) NOT NULL DEFAULT '-1' COMMENT '分区ID',
  `leader_broker_id` int(11) NOT NULL DEFAULT '-1' COMMENT '分区的LeaderBroker，-1表示无Leader',
  `in_sync_replicas` varchar(512) NOT NULL DEFAULT '-1' COMMENT 'ISR',
  `assign_replicas` varchar(512) NOT NULL DEFAULT '-1' COMMENT 'AR',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_topic_partition` (`cluster_phy_id`,`topic_name`,`partition_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Partition信息表';



DROP TABLE IF EXISTS `ks_km_physical_cluster`;
CREATE TABLE `ks_km_physical_cluster` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '集群id',
  `name` varchar(128) NOT NULL DEFAULT '' COMMENT '集群名称',
  `zookeeper` varchar(2048) NOT NULL DEFAULT '' COMMENT 'zk地址',
  `bootstrap_servers` varchar(2048) NOT NULL DEFAULT '' COMMENT 'server地址',
  `kafka_version` varchar(32) NOT NULL DEFAULT '' COMMENT 'kafka版本',
  `client_properties` text COMMENT 'Kafka客户端配置',
  `jmx_properties` text COMMENT 'JMX配置',
  `zk_properties` text COMMENT 'ZK配置',
  `description` text COMMENT '备注',
  `auth_type` int(11) NOT NULL DEFAULT '0' COMMENT '认证类型，-1未知，0:无认证，',
  `run_state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '运行状态, 0表示未监控, 1监控中，有ZK，2:监控中，无ZK',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '接入时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='物理集群信息表';



DROP TABLE IF EXISTS `ks_km_platform_cluster_config`;
CREATE TABLE `ks_km_platform_cluster_config` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `value_group` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项组',
  `value_name` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项名字',
  `value` text COMMENT '配置项的值',
  `description` text COMMENT '备注',
  `operator` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '操作者',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_id_group_name` (`cluster_id`,`value_group`,`value_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='KS平台集群配置';



DROP TABLE IF EXISTS `ks_km_reassign_job`;
CREATE TABLE `ks_km_reassign_job` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `reassignment_json` text COMMENT '迁移计划',
  `throttle_unit_byte` bigint(20) NOT NULL DEFAULT '0' COMMENT '限流值',
  `start_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '任务开始时间',
  `finished_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '任务完成时间',
  `creator` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人',
  `description` text COMMENT '备注',
  `status` int(16) NOT NULL DEFAULT '0' COMMENT '任务状态',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='迁移Job信息';



DROP TABLE IF EXISTS `ks_km_reassign_sub_job`;
CREATE TABLE `ks_km_reassign_sub_job` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `job_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '父任务ID',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群id',
  `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称',
  `partition_id` int(11) NOT NULL DEFAULT '-1' COMMENT '分区ID',
  `original_broker_ids` text COMMENT '源BrokerId列表',
  `reassign_broker_ids` text COMMENT '目标BrokerId列表',
  `start_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '任务开始时间',
  `finished_time` timestamp NOT NULL DEFAULT '1971-1-1 00:00:00' COMMENT '任务完成时间',
  `extend_data` text COMMENT '扩展数据',
  `status` int(16) NOT NULL DEFAULT '0' COMMENT '任务状态',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '任务创建时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '任务修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='迁移SubJob信息';



DROP TABLE IF EXISTS `ks_km_topic`;
CREATE TABLE `ks_km_topic` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID',
  `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称',
  `replica_num` int(11) NOT NULL DEFAULT '-1' COMMENT '副本数',
  `partition_num` int(11) NOT NULL DEFAULT '-1' COMMENT '分区数',
  `broker_ids` varchar(2048) NOT NULL DEFAULT '' COMMENT 'BrokerId列表',
  `partition_map` text COMMENT '分区分布信息',
  `retention_ms` bigint(20) NOT NULL DEFAULT '-2' COMMENT '保存时间，-2：未知，-1：无限制，>=0对应时间，单位ms',
  `type` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Topic类型，默认0，0:普通，1:Kafka内部',
  `description` text COMMENT '备注信息',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_cluster_phy_id_topic_name` (`cluster_phy_id`,`topic_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Topic信息表';


DROP TABLE IF EXISTS `ks_km_app_node`;
CREATE TABLE `ks_km_app_node` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
    `host_name` varchar(256) NOT NULL DEFAULT '' COMMENT 'host',
    `ip` varchar(256) NOT NULL DEFAULT '' COMMENT 'ip',
    `beat_time`   timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'node 的心跳时间',
    `app_name` varchar(128) NOT NULL DEFAULT '' COMMENT 'km 集群的应用名',
    `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`),
    KEY `idx_app_host` (`app_name`,`host_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='km集群部署的node信息';
-- Logi-Job模块的sql，安装KS-KM需要执行该sql


DROP TABLE IF EXISTS `logi_job`;
CREATE TABLE `logi_job` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `job_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'task taskCode',
  `task_code` varchar(255) NOT NULL DEFAULT '' COMMENT '任务code',
  `class_name` varchar(255) NOT NULL DEFAULT '' COMMENT '类的全限定名',
  `try_times` int(10) NOT NULL DEFAULT '0' COMMENT '第几次重试',
  `worker_code` varchar(200) NOT NULL DEFAULT '' COMMENT '执行机器',
  `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT '被调度的应用名称',
  `start_time` datetime DEFAULT '1971-01-01 00:00:00' COMMENT '开始时间',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `job_code` (`job_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='正在执行的job信息';



DROP TABLE IF EXISTS `logi_job_log`;
CREATE TABLE `logi_job_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `job_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'job taskCode',
  `task_code` varchar(255) NOT NULL DEFAULT '' COMMENT '任务code',
  `task_name` varchar(255) NOT NULL DEFAULT '' COMMENT '任务名称',
  `task_desc` varchar(255) NOT NULL DEFAULT '' COMMENT '任务描述',
  `task_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '任务id',
  `class_name` varchar(255) NOT NULL DEFAULT '' COMMENT '类的全限定名',
  `try_times` int(10) NOT NULL DEFAULT '0' COMMENT '第几次重试',
  `worker_code` varchar(200) NOT NULL DEFAULT '' COMMENT '执行机器',
  `worker_ip` varchar(200) NOT NULL DEFAULT '' COMMENT '执行机器ip',
  `start_time` datetime DEFAULT '1971-01-01 00:00:00' COMMENT '开始时间',
  `end_time` datetime DEFAULT '1971-01-01 00:00:00' COMMENT '结束时间',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '执行结果 1成功 2失败 3取消',
  `error` text NOT NULL COMMENT '错误信息',
  `result` text NOT NULL COMMENT '执行结果',
  `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT '被调度的应用名称',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `index_job_code` (`job_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='job执行历史日志';



DROP TABLE IF EXISTS `logi_task`;
CREATE TABLE `logi_task` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `task_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'task taskCode',
  `task_name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
  `task_desc` varchar(1000) NOT NULL DEFAULT '' COMMENT '任务描述',
  `cron` varchar(100) NOT NULL DEFAULT '' COMMENT 'cron 表达式',
  `class_name` varchar(255) NOT NULL DEFAULT '' COMMENT '类的全限定名',
  `params` varchar(1000) NOT NULL DEFAULT '' COMMENT '执行参数 map 形式{key1:value1,key2:value2}',
  `retry_times` int(10) NOT NULL DEFAULT '0' COMMENT '允许重试次数',
  `last_fire_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '上次执行时间',
  `timeout` bigint(20) NOT NULL DEFAULT '0' COMMENT '超时 毫秒',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1等待 2运行中 3暂停',
  `sub_task_codes` varchar(1000) NOT NULL DEFAULT '' COMMENT '子任务code列表,逗号分隔',
  `consensual` varchar(200) NOT NULL DEFAULT '' COMMENT '执行策略',
  `owner` varchar(200) NOT NULL DEFAULT '' COMMENT '责任人',
  `task_worker_str` varchar(3000) NOT NULL DEFAULT '' COMMENT '机器执行信息',
  `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT '被调度的应用名称',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `task_code` (`task_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务信息';



DROP TABLE IF EXISTS `logi_task_lock`;
CREATE TABLE `logi_task_lock` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `task_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'task taskCode',
  `worker_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'worker taskCode',
  `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT '被调度的应用名称',
  `expire_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '过期时间',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务锁';



DROP TABLE IF EXISTS `logi_worker`;
CREATE TABLE `logi_worker` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `worker_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'worker taskCode',
  `worker_name` varchar(100) NOT NULL DEFAULT '' COMMENT 'worker名',
  `ip` varchar(100) NOT NULL DEFAULT '' COMMENT 'worker的ip',
  `cpu` int(11) NOT NULL DEFAULT '0' COMMENT 'cpu数量',
  `cpu_used` double NOT NULL DEFAULT '0' COMMENT 'cpu使用率',
  `memory` double NOT NULL DEFAULT '0' COMMENT '内存,以M为单位',
  `memory_used` double NOT NULL DEFAULT '0' COMMENT '内存使用率',
  `jvm_memory` double NOT NULL DEFAULT '0' COMMENT 'jvm堆大小，以M为单位',
  `jvm_memory_used` double NOT NULL DEFAULT '0' COMMENT 'jvm堆使用率',
  `job_num` int(10) NOT NULL DEFAULT '0' COMMENT '正在执行job数',
  `heartbeat` datetime DEFAULT '1971-01-01 00:00:00' COMMENT '心跳时间',
  `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT '被调度的应用名称',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `worker_code` (`worker_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='worker信息';



DROP TABLE IF EXISTS `logi_worker_blacklist`;
CREATE TABLE `logi_worker_blacklist` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `worker_code` varchar(100) NOT NULL DEFAULT '' COMMENT 'worker taskCode',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `worker_code` (`worker_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='worker黑名单列表';

DROP TABLE IF EXISTS `logi_security_dept`;
CREATE TABLE `logi_security_dept`
(
    id          int auto_increment  primary key,
    dept_name   varchar(10) not null comment '部门名',
    parent_id   int         not null comment '父部门id',
    leaf        tinyint(1)  not null comment '是否叶子部门',
    level       tinyint     not null comment 'parentId为0的层级为1',
    description varchar(20) null comment '描述',
    create_time timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete   tinyint(1) default 0                 null comment '逻辑删除',
    app_name    varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '部门信息表';

DROP TABLE IF EXISTS `logi_security_message`;
CREATE TABLE `logi_security_message`
(
    id          int auto_increment primary key,
    title       varchar(60)                          not null comment '标题',
    content     varchar(256)                         null comment '内容',
    read_tag    tinyint(1) default 0                 null comment '是否已读',
    oplog_id    int                                  null comment '操作日志id',
    user_id     int                                  null comment '这条消息属于哪个用户的，用户id',
    create_time timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete   tinyint(1) default 0                 null comment '逻辑删除',
    app_name    varchar(16)                          null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '消息中心';

DROP TABLE IF EXISTS `logi_security_oplog`;
CREATE TABLE `logi_security_oplog`
(
    id                int auto_increment primary key,
    operator_ip       varchar(64)                          not null comment '操作者ip',
    operator          varchar(64)                          null comment '操作者账号',
    operate_page      varchar(64)                          not null default '' comment '操作页面',
    operate_type      varchar(64)                          not null comment '操作类型',
    target_type       varchar(64)                          not null comment '对象分类',
    target            varchar(1024)                        not null comment '操作对象',
    operation_methods            varchar(64)               not null default '' comment '操作方式',
    detail            text                                 null comment '日志详情',
    create_time       timestamp  default CURRENT_TIMESTAMP null,
    update_time       timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete         tinyint(1) default 0                 not null comment '逻辑删除',
    app_name          varchar(16)                          null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '操作日志';


DROP TABLE IF EXISTS `logi_security_oplog_extra`;
CREATE TABLE `logi_security_oplog_extra`
(
    id          int auto_increment primary key,
    info        varchar(16) null comment '信息',
    type        tinyint     not null comment '哪种信息：1：操作页面;2：操作类型;3：对象分类',
    create_time timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete   tinyint(1) default 0                 null comment '逻辑删除',
    app_name    varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '操作日志信息（操作页面、操作类型、对象分类）';

DROP TABLE IF EXISTS `logi_security_permission`;
CREATE TABLE `logi_security_permission`
(
    id              int auto_increment primary key,
    permission_name varchar(40) not null comment '权限名字',
    parent_id       int         not null comment '父权限id',
    leaf            tinyint(1)  not null comment '是否叶子权限点（具体的操作）',
    level           tinyint     not null comment '权限点的层级（parentId为0的层级为1）',
    description     varchar(64) null comment '权限点描述',
    create_time     timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time     timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete       tinyint(1) default 0                 null comment '逻辑删除',
    app_name        varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '权限表';

DROP TABLE IF EXISTS `logi_security_project`;
CREATE TABLE `logi_security_project`
(
    id           int auto_increment comment '项目id'     primary key,
    project_code varchar(128)                           not null comment '项目编号',
    project_name varchar(128)                           not null comment '项目名',
    description  varchar(512) default ''                not null comment '项目描述',
    dept_id      int                                    not null comment '部门id',
    running      tinyint(1)   default 1                 not null comment '启用 or 停用',
    create_time  timestamp    default CURRENT_TIMESTAMP null comment '创建时间',
    update_time  timestamp    default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete    tinyint(1)   default 0                 not null comment '逻辑删除',
    app_name     varchar(16)                            null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '项目表';

DROP TABLE IF EXISTS `logi_security_resource_type`;
CREATE TABLE `logi_security_resource_type`
(
    id              int auto_increment primary key,
    type_name       varchar(16) null comment '资源类型名',
    create_time     timestamp    default CURRENT_TIMESTAMP null comment '创建时间',
    update_time     timestamp    default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete       tinyint(1)   default 0                 not null comment '逻辑删除',
    app_name        varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '资源类型表';

DROP TABLE IF EXISTS `logi_security_role`;
CREATE TABLE `logi_security_role`
(
    id           int auto_increment primary key,
    role_code    varchar(128)                         not null comment '角色编号',
    role_name    varchar(128)                         not null comment '名称',
    description  varchar(128)                         null comment '角色描述',
    last_reviser varchar(30)                          null comment '最后修改人',
    create_time  timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time  timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete    tinyint(1) default 0                 not null comment '逻辑删除',
    app_name     varchar(16)                          null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '角色信息';

DROP TABLE IF EXISTS `logi_security_role_permission`;
CREATE TABLE `logi_security_role_permission`
(
    id              int auto_increment primary key,
    role_id         int         not null comment '角色id',
    permission_id   int         not null comment '权限id',
    create_time     timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time     timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete       tinyint(1) default 0                 not null comment '逻辑删除',
    app_name        varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '角色权限表（只保留叶子权限与角色关系）';

DROP TABLE IF EXISTS `logi_security_user`;
CREATE TABLE `logi_security_user`
(
    id          int auto_increment primary key,
    user_name   varchar(64)                            not null comment '用户账号',
    pw          varchar(2048)                          not null comment '用户密码',
    salt        char(5)      default ''                not null comment '密码盐',
    real_name   varchar(128) default ''                not null comment '真实姓名',
    phone       char(11)     default ''                not null comment 'mobile',
    email       varchar(30)  default ''                not null comment 'email',
    dept_id     int                                    null comment '所属部门id',
    is_delete   tinyint(1)   default 0                 not null comment '逻辑删除',
    create_time timestamp    default CURRENT_TIMESTAMP null comment '注册时间',
    update_time timestamp    default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    app_name    varchar(16)                            null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '用户信息';

DROP TABLE IF EXISTS `logi_security_user_project`;
CREATE TABLE `logi_security_user_project`
(
    id              int auto_increment primary key,
    user_id         int         not null comment '用户id',
    project_id      int         not null comment '项目id',
    create_time     timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time     timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete       tinyint(1) default 0                 not null comment '逻辑删除',
    app_name        varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '用户项目关系表（项目负责人）';

DROP TABLE IF EXISTS `logi_security_user_resource`;
CREATE TABLE `logi_security_user_resource`
(
    id                  int auto_increment primary key,
    user_id             int         not null comment '用户id',
    project_id          int         not null comment '资源所属项目id',
    resource_type_id    int         not null comment '资源类别id',
    resource_id         int         not null comment '资源id',
    control_level       tinyint     not null comment '管理级别：1（查看权限）2（管理权限）',
    create_time         timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time         timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete           tinyint(1) default 0                 not null comment '逻辑删除',
    app_name            varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '用户和资源关系表';

DROP TABLE IF EXISTS `logi_security_user_role`;
CREATE TABLE `logi_security_user_role`
(
    id              int auto_increment primary key,
    user_id         int         not null comment '用户id',
    role_id         int         not null comment '角色id',
    create_time     timestamp  default CURRENT_TIMESTAMP null comment '创建时间',
    update_time     timestamp  default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    is_delete       tinyint(1) default 0                 not null comment '逻辑删除',
    app_name        varchar(16) null comment '应用名称'
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 comment '用户角色表';


DROP TABLE IF EXISTS `logi_security_config`;
CREATE TABLE `logi_security_config`
(
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增',
    `value_group` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项组',
    `value_name` varchar(100) NOT NULL DEFAULT '' COMMENT '配置项名字',
    `value` text COMMENT '配置项的值',
    `edit` int(4) NOT NULL DEFAULT '1' COMMENT '是否可以编辑 1 不可编辑（程序获取） 2 可编辑',
    `status` int(4) NOT NULL DEFAULT '1' COMMENT '1 正常 2 禁用',
    `memo` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注',
    `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `is_delete` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除',
    `app_name` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '应用名称',
    `operator` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '操作者',
    PRIMARY KEY (`id`),
    KEY `idx_group_name` (`value_group`,`value_name`)
) ENGINE=InnoDB AUTO_INCREMENT=1592 DEFAULT CHARSET=utf8 COMMENT='logi配置项';

INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_CONNECTOR_FAILED_TASK_COUNT', '{\"value\" : 1}', 'connector失败状态的任务数量', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_CONNECTOR_UNASSIGNED_TASK_COUNT', '{\"value\" : 1}', 'connector未被分配的任务数量', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_CONNECT_CLUSTER_TASK_STARTUP_FAILURE_PERCENTAGE', '{\"value\" : 0.05}', 'Connect集群任务启动失败概率', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_CLUSTER_NO_CONTROLLER','{  \"value\": 1,   \"weight\": 30 } ','集群Controller数正常','know-streaming');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_BROKER_REQUEST_QUEUE_FULL','{  \"value\": 10,  \"weight\": 20 } ','Broker-RequestQueueSize指标','know-streaming');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_BROKER_NETWORK_PROCESSOR_AVG_IDLE_TOO_LOW','{  \"value\": 0.8,   \"weight\": 20 } ','Broker-NetworkProcessorAvgIdlePercent指标','know-streaming');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_GROUP_RE_BALANCE_TOO_FREQUENTLY','{\n  \"latestMinutes\": 10,\n  \"detectedTimes\": 8,\n \"weight\": 10\n}\n','Group的re-balance频率','know-streaming');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_TOPIC_NO_LEADER','{  \"value\": 1,   \"weight\": 10 } ','Topic 无Leader数','know-stream');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`,`value_group`,`value_name`,`value`,`description`,`operator`) VALUES (-1,'HEALTH','HC_TOPIC_UNDER_REPLICA_TOO_LONG','{   \"latestMinutes\": 10,  \"detectedTimes\": 8,   \"weight\": 10 } ','Topic 未同步持续时间','know-streaming');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_BRAIN_SPLIT', '{ 	\"value\": 1} ', 'ZK 脑裂', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_OUTSTANDING_REQUESTS', '{ 	\"amount\": 100, \"ratio\":0.8} ', 'ZK Outstanding 请求堆积数', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_WATCH_COUNT', '{ 	\"amount\": 100000, 	\"ratio\": 0.8 } ', 'ZK WatchCount 数', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_ALIVE_CONNECTIONS', '{ 	\"amount\": 10000, 	\"ratio\": 0.8 } ', 'ZK 连接数', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_APPROXIMATE_DATA_SIZE', '{ 	\"amount\": 524288000, 	\"ratio\": 0.8 } ', 'ZK 数据大小(Byte)', 'admin');
INSERT INTO `ks_km_platform_cluster_config` (`cluster_id`, `value_group`, `value_name`, `value`, `description`, `operator`) VALUES ('-1', 'HEALTH', 'HC_ZK_SENT_RATE', '{ 	\"amount\": 500000, 	\"ratio\": 0.8 } ', 'ZK 发包数', 'admin');
-- 初始化权限
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1593', '多集群管理', '0', '0', '1', '多集群管理', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1595', '系统管理', '0', '0', '1', '系统管理', '0', 'know-streaming');

-- 多集群管理权限
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1597', '接入集群', '1593', '1', '2', '接入集群', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1599', '删除集群', '1593', '1', '2', '删除集群', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1601', 'Cluster-修改集群信息', '1593', '1', '2', 'Cluster-修改集群信息', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1603', 'Cluster-修改健康规则', '1593', '1', '2', 'Cluster-修改健康规则', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1605', 'Broker-修改Broker配置', '1593', '1', '2', 'Broker-修改Broker配置', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1607', 'Topic-新增Topic', '1593', '1', '2', 'Topic-新增Topic', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1609', 'Topic-扩分区', '1593', '1', '2', 'Topic-扩分区', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1611', 'Topic-删除Topic', '1593', '1', '2', 'Topic-扩分区', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1613', 'Topic-重置Offset', '1593', '1', '2', 'Topic-重置Offset', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1615', 'Topic-修改Topic配置', '1593', '1', '2', 'Topic-修改Topic配置', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1617', 'Consumers-重置Offset', '1593', '1', '2', 'Consumers-重置Offset', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1619', 'Test-Producer', '1593', '1', '2', 'Test-Producer', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1621', 'Test-Consumer', '1593', '1', '2', 'Test-Consumer', '0', 'know-streaming');

-- 系统管理权限
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1623', '配置管理-新增配置', '1595', '1', '2', '配置管理-新增配置', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1625', '配置管理-编辑配置', '1595', '1', '2', '配置管理-编辑配置', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1627', '配置管理-删除配置', '1595', '1', '2', '配置管理-删除配置', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1629', '用户管理-新增人员', '1595', '1', '2', '用户管理-新增人员', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1631', '用户管理-编辑人员', '1595', '1', '2', '用户管理-编辑人员', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1633', '用户管理-修改人员密码', '1595', '1', '2', '用户管理-修改人员密码', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1635', '用户管理-删除人员', '1595', '1', '2', '用户管理-删除人员', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1637', '用户管理-新增角色', '1595', '1', '2', '用户管理-新增角色', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1639', '用户管理-编辑角色', '1595', '1', '2', '用户管理-编辑角色', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1641', '用户管理-分配用户角色', '1595', '1', '2', '用户管理-分配用户角色', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('1643', '用户管理-删除角色', '1595', '1', '2', '用户管理-删除角色', '0', 'know-streaming');

-- 多集群管理权限2022-09-06新增
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2000', '多集群管理查看', '1593', '1', '2', '多集群管理查看', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2002', 'Topic-迁移副本', '1593', '1', '2', 'Topic-迁移副本', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2004', 'Topic-扩缩副本', '1593', '1', '2', 'Topic-扩缩副本', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2006', 'Cluster-LoadReBalance-周期均衡', '1593', '1', '2', 'Cluster-LoadReBalance-周期均衡', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2008', 'Cluster-LoadReBalance-立即均衡', '1593', '1', '2', 'Cluster-LoadReBalance-立即均衡', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2010', 'Cluster-LoadReBalance-设置集群规格', '1593', '1', '2', 'Cluster-LoadReBalance-设置集群规格', '0', 'know-streaming');


-- 系统管理权限2022-09-06新增
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('3000', '系统管理查看', '1595', '1', '2', '系统管理查看', '0', 'know-streaming');






-- 初始化用户
-- INSERT INTO `logi_security_user` (`id`, `user_name`, `pw`, `real_name`, `is_delete`, `app_name`) VALUES ('1', 'admin', 'V1ZkU2RHRlhOSGxOUkVsNVdETjBRVlp0Y0V0T1IwWnlaVEZ6YWxGRVJrRkpNVEU1VTJwYVUySkhlRzlSU0RBOWUwQldha28wWVd0N1d5TkFNa0FqWFgxS05sSnNiR2hBZlE9PXtAVmpKNGFre1sjQDNAI119SjZSbGxoQH0=Mv{#cdRgJ45Lqx}3IubEW87!==', '系统管理员', '0', 'know-streaming');
INSERT INTO `logi_security_user` (`id`, `user_name`, `pw`, `real_name`, `is_delete`, `app_name`) VALUES ('1', 'admin', 'V1ZkU2RHRlhOVGRSUmxweFUycFNhR0V6ZEdKSk1FRjRVVU5PWkdaVmJ6SlZiWGh6WVVWQ09YdEFWbXBLTkdGcmUxc2pRREpBSTExOVNqWlNiR3hvUUgwPXtAVmpKNGFre1sjQDNAI119SjZSbGxoQH0=Mv{#cdRgJ45Lqx}3IubEW87!==', '系统管理员', '0', 'know-streaming');

-- 初始化角色
INSERT INTO `logi_security_role` (`id`, `role_code`, `role_name`, `description`, `last_reviser`, `is_delete`, `app_name`) VALUES ('1677', 'r15477137', '管理员角色', '包含系统所有权限', 'admin', '0', 'know-streaming');

-- 初始化角色权限关系
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1597', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1599', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1601', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1603', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1605', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1607', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1609', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1611', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1613', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1615', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1617', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1619', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1621', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1593', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1623', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1625', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1627', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1629', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1631', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1633', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1635', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1637', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1639', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1641', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1643', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '1595', '0', 'know-streaming');

INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2000', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2002', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2004', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2006', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2008', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2010', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '3000', '0', 'know-streaming');

-- 初始化 用户角色关系
INSERT INTO `logi_security_user_role` (`id`, `user_id`, `role_id`, `is_delete`, `app_name`) VALUES ('1', '1', '1677', '0', 'know-streaming');

INSERT INTO `logi_security_config`
(`value_group`,`value_name`,`value`,`edit`,`status`,`memo`,`is_delete`,`app_name`,`operator`)
VALUES
('SECURITY.LOGIN','SECURITY.TRICK_USERS','[\n  \"admin\"\n]',1,1,'允许跳过登录的用户',0,'know-streaming','admin');

