CREATE DATABASE `saas_manage` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use `saas_manage`;

create table `datacenter` (
  name varchar(30) primary key not null,
  description varchar(300) comment '描述'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据中心';

create table `datasource` (
  id int primary key not null auto_increment,
  dc_name varchar(30) not null,
  db_name varchar(30) not null comment '数据库名',
  db_realname varchar(30) comment '数据库真实名',
  db_host varchar(100) comment '数据库服务器',
  db_port int comment '数据库端口',
  db_username varchar(30) comment '数据库登录账号',
  db_password varchar(64) comment '数据库登录密码'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据连接';

create table `backup` (
  id int unsigned primary key not null auto_increment,
  file_path int unsigned comment '文件ID',
  create_time datetime comment '创建时间',
  creator_id int unsigned comment '创建人',
  company_id int unsigned comment '公司',
  status smallint comment '状态',
  message varchar(1000) comment '错误信息'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='按公司数据备份';

create table `help_doc_project`
(
id int unsigned primary key not null auto_increment,
code varchar(50) not null comment '编码',
name varchar(100) not null comment '名称',
homepage varchar(50) comment '首页',
creator_id int unsigned,
creator_name varchar(100),
create_time datetime,
updater_id int unsigned,
updater_name varchar(100),
update_time datetime
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文档项目';

create table `help_doc_item`
(
id int unsigned primary key not null auto_increment,
project_id int unsigned not null,
parent_id int unsigned,
code varchar(50) not null comment '编码',
name varchar(100) not null comment '名称',
article boolean default 1 comment '是否文档',
order_num int comment '顺序',
creator_id int unsigned,
creator_name varchar(100),
create_time datetime,
updater_id int unsigned,
updater_name varchar(100),
update_time datetime
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文档目录';