drop table if exists task_worker;
CREATE TABLE task_worker (
  id bigint NOT NULL AUTO_INCREMENT,
  name varchar(64) DEFAULT NULL,
  status varchar(24) DEFAULT NULL,
  remark varchar(256) DEFAULT NULL,
  is_deleted tinyint(1) NOT NULL COMMENT '是否删除',
  props varchar(1024) DEFAULT NULL COMMENT '其他属性',
  gmt_create datetime DEFAULT NULL COMMENT '创建时间',
  gmt_modify datetime DEFAULT NULL COMMENT '修改时间',
  creator_id bigint DEFAULT NULL COMMENT '创建者ID',
  mender_id bigint DEFAULT NULL COMMENT '修改者ID',
  owner_id bigint DEFAULT NULL COMMENT '任务类型',
  instance varchar(255) DEFAULT NULL,
  category varchar(255) DEFAULT NULL,
  protocol varchar(255) DEFAULT NULL,
  uri varchar(255) DEFAULT NULL,
  username varchar(255) DEFAULT NULL,
  password varchar(255) DEFAULT NULL,
  count bigint DEFAULT NULL,
  is_super tinyint(1) DEFAULT NULL,
  group_id bigint DEFAULT NULL,
  PRIMARY KEY (id)
);
drop table if exists task_host;
CREATE TABLE task_host (
  id bigint NOT NULL AUTO_INCREMENT,
  model_code varchar(64) DEFAULT NULL,
  model_name varchar(256) DEFAULT NULL,
  dc_id varchar(256) DEFAULT NULL,
  dc_name varchar(256) DEFAULT NULL,
  all_ip text,
  in_manage_ip text,
  out_manage_ip text,
  ip varchar(256) DEFAULT NULL COMMENT '纳管IP',
  os_code varchar(64) DEFAULT NULL,
  os_name varchar(256) DEFAULT NULL,
  category varchar(64) DEFAULT NULL COMMENT '分类vm:虚拟机，pm：物理机',
  state int DEFAULT NULL COMMENT '状态{0-可纳管，1-有账号密码，2-无账号密码}',
  segment_id bigint DEFAULT NULL COMMENT '管理网段Id',
  known tinyint(1) DEFAULT NULL,
  salt_known tinyint(1) DEFAULT NULL COMMENT 'Salt纳管状态',
  PRIMARY KEY (id)
);
drop table if exists task_host_statistics;
CREATE TABLE task_host_statistics (
  id bigint NOT NULL AUTO_INCREMENT,
  segment_id bigint DEFAULT NULL COMMENT '网段ID',
  catalog varchar(255) DEFAULT NULL COMMENT '主机类型(PM|VM)',
  category varchar(255) DEFAULT NULL COMMENT '操作系统类型(windows|centos等等',
  ansible_count int DEFAULT NULL COMMENT 'ansible纳管数量',
  saltstack_count int DEFAULT NULL COMMENT 'saltstack纳管数量',
  ris_count int DEFAULT NULL COMMENT '具有ris账号数据',
  host_count int DEFAULT NULL COMMENT '主机数量',
  PRIMARY KEY (id)
);
drop table if exists network_group;
CREATE TABLE network_group (
  id bigint NOT NULL AUTO_INCREMENT,
  remark varchar(255) DEFAULT NULL COMMENT '网段',
  name varchar(255) DEFAULT NULL,
  is_deleted tinyint DEFAULT '0',
  gmt_create datetime NOT NULL COMMENT '创建时间',
  gmt_modify datetime DEFAULT NULL COMMENT '修改时间',
  creator_id bigint NOT NULL COMMENT '创建者ID',
  mender_id bigint DEFAULT NULL COMMENT '修改者ID',
  owner_id bigint DEFAULT NULL COMMENT '任务类型',
  status varchar(16) DEFAULT NULL COMMENT '状态',
  props varchar(1024) DEFAULT NULL COMMENT '其他属性',
  PRIMARY KEY (id)
);
drop table if exists network_segment;
CREATE TABLE network_segment (
  id bigint NOT NULL AUTO_INCREMENT,
  group_id bigint DEFAULT NULL,
  remark varchar(255) DEFAULT NULL COMMENT '网段',
  name varchar(255) DEFAULT NULL,
  is_deleted tinyint DEFAULT '0',
  gmt_create datetime NOT NULL COMMENT '创建时间',
  gmt_modify datetime DEFAULT NULL COMMENT '修改时间',
  creator_id bigint NOT NULL COMMENT '创建者ID',
  mender_id bigint DEFAULT NULL COMMENT '修改者ID',
  owner_id bigint DEFAULT NULL COMMENT '任务类型',
  status varchar(16) DEFAULT NULL COMMENT '状态',
  props varchar(1024) DEFAULT NULL COMMENT '其他属性',
  PRIMARY KEY (id)
);
drop table if exists task_inspection_record;
CREATE TABLE task_inspection_record (
  id bigint NOT NULL AUTO_INCREMENT,
  target bigint DEFAULT NULL COMMENT '操作对象',
  ip varchar(32) DEFAULT NULL COMMENT '行为',
  status varchar(32) DEFAULT NULL,
  message longtext COMMENT '操作者id',
  content longtext COMMENT '操作者名称',
  gmt_create datetime DEFAULT NULL COMMENT '创建时间',
  operator bigint DEFAULT NULL,
  PRIMARY KEY (id) USING BTREE,
  KEY index_gmt_create (gmt_create)
);
drop table if exists task_worker;
CREATE TABLE task_worker (
  id bigint NOT NULL AUTO_INCREMENT,
  name varchar(64) DEFAULT NULL,
  status varchar(24) DEFAULT NULL,
  remark varchar(256) DEFAULT NULL,
  is_deleted tinyint(1) NOT NULL COMMENT '是否删除',
  props varchar(1024) DEFAULT NULL COMMENT '其他属性',
  gmt_create datetime DEFAULT NULL COMMENT '创建时间',
  gmt_modify datetime DEFAULT NULL COMMENT '修改时间',
  creator_id bigint DEFAULT NULL COMMENT '创建者ID',
  mender_id bigint DEFAULT NULL COMMENT '修改者ID',
  owner_id bigint DEFAULT NULL COMMENT '任务类型',
  instance varchar(255) DEFAULT NULL,
  category varchar(255) DEFAULT NULL,
  protocol varchar(255) DEFAULT NULL,
  uri varchar(255) DEFAULT NULL,
  username varchar(255) DEFAULT NULL,
  password varchar(255) DEFAULT NULL,
  count bigint DEFAULT NULL,
  is_super tinyint(1) DEFAULT NULL,
  group_id bigint DEFAULT NULL,
  PRIMARY KEY (id)
);
INSERT INTO task_node_module (name, status, remark, is_deleted, props, gmt_create, gmt_modify, creator_id, mender_id, owner_id, code, pre_constraints, post_constraints, icon, internal, group_id, group_ids, template, params, shape, requires) VALUES ('HostsAllow操作', 'AVAILABLE', 'HostsAllow操作', '0', NULL, '2018-12-20 16:22:12', '2018-12-20 16:22:12', '1', '1', NULL, 'task.maintain.hostallow', '{\"rule\":\"free\"}', '{\"rule\":\"free\"}', '/static/img/graph/script.png', '1', '4', NULL, NULL, NULL, '{\"shape\":\"maintain-node\"}', NULL);
