-- MySQL Script generated by MySQL Workbench
-- 12/15/15 10:31:42
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Table `user_info`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user_info` ;

CREATE TABLE IF NOT EXISTS `user_info` (
  `uid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_name` VARCHAR(100) NOT NULL,
  `password` VARCHAR(32) NOT NULL,
  `role_type` VARCHAR(45) NOT NULL DEFAULT 'user',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `sts` VARCHAR(2) NOT NULL,
  `modify_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`uid`),
  UNIQUE INDEX `user_name_UNIQUE` (`user_name` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `user_info_ext`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `user_info_ext` ;

CREATE TABLE IF NOT EXISTS `user_info_ext` (
  `eid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `uid` INT NOT NULL,
  `email` VARCHAR(200) NULL,
  `create_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`eid`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `login_log`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `login_log` ;

CREATE TABLE IF NOT EXISTS `login_log` (
  `log_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `uid` INT NOT NULL,
  `login_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`log_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `application_info`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `application_info` ;

CREATE TABLE IF NOT EXISTS `application_info` (
  `app_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `uid` INT NOT NULL,
  `app_code` VARCHAR(200) NOT NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(2) NULL,
  PRIMARY KEY (`app_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `data_info`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `data_info` ;

CREATE TABLE IF NOT EXISTS `data_info` (
  `did` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `tab_info` VARCHAR(45) NOT NULL,
  `col_info` VARCHAR(45) NOT NULL,
  `code` VARCHAR(45) NOT NULL,
  `word` VARCHAR(45) NOT NULL,
  `code_desc` VARCHAR(200) NULL,
  `order_id` INT UNSIGNED NULL,
  `create_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `sts` VARCHAR(2) NULL,
  `modify_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  `parent_did` INT UNSIGNED NULL,
  PRIMARY KEY (`did`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `alarm_rule`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `alarm_rule` ;

CREATE TABLE IF NOT EXISTS `alarm_rule` (
  `rule_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `app_id` VARCHAR(45) NULL,
  `uid` VARCHAR(45) NOT NULL,
  `is_global` VARCHAR(2) NOT NULL,
  `todo_type` VARCHAR(4) NOT NULL,
  `config_args` VARCHAR(2000) NULL,
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `sts` VARCHAR(2) NULL,
  `modify_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`rule_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `include_rule`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `include_rule` ;

CREATE TABLE IF NOT EXISTS `include_rule` (
  `irid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `rule_value` VARCHAR(200) NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(2) NULL,
  `rule_id` INT UNSIGNED NOT NULL,
  PRIMARY KEY (`irid`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exclude_rule`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `exclude_rule` ;

CREATE TABLE IF NOT EXISTS `exclude_rule` (
  `erid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `rule_value` VARCHAR(200) NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(2) NULL,
  `rule_id` INT UNSIGNED NOT NULL,
  PRIMARY KEY (`erid`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `email_expression`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `email_expression` ;

CREATE TABLE IF NOT EXISTS `email_expression` (
  `tid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `expr_name` VARCHAR(100) NOT NULL,
  `expr_val` VARCHAR(100) NOT NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(2) NULL,
  PRIMARY KEY (`tid`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `system_config`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `system_config` ;

CREATE TABLE IF NOT EXISTS `system_config` (
  `config_id` INT UNSIGNED NOT NULL,
  `conf_key` VARCHAR(200) NOT NULL,
  `conf_value` VARCHAR(500) NOT NULL,
  `val_type` VARCHAR(45) NOT NULL,
  `val_desc` VARCHAR(200) NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(2) NOT NULL,
  `modify_time` DATETIME NULL,
  PRIMARY KEY (`config_id`),
  UNIQUE INDEX `conf_key_UNIQUE` (`conf_key` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `app_auth_info`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `app_auth_info` ;

CREATE TABLE IF NOT EXISTS `app_auth_info` (
  `info_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `app_id` VARCHAR(45) NOT NULL,
  `auth_json` VARCHAR(3000) NOT NULL,
  `create_time` DATETIME NULL,
  `sts` VARCHAR(45) NULL,
  `modify_time` DATETIME NULL,
  PRIMARY KEY (`info_id`))
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;


CREATE TABLE `auth_file_config` (
  `config_id` INT(11) NOT NULL,
  `key` VARCHAR(200) NOT NULL,
  `value0` VARCHAR(200) NULL,
  `value1` VARCHAR(200) NULL DEFAULT NULL,
  `value2` VARCHAR(200) NULL DEFAULT NULL,
  `value3` VARCHAR(200) NULL DEFAULT NULL,
  `value4` VARCHAR(200) NULL DEFAULT NULL,
  `key_desc` VARCHAR(500) NULL,
  `sts` VARCHAR(2) NULL,
  PRIMARY KEY (`config_id`));


  CREATE TABLE `sw_chain_info` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `viewpoint` VARCHAR(1024) NULL,
  `cid` VARCHAR(32) NULL,
  `uid` VARCHAR(32) NULL,
  `parentLevelId` VARCHAR(32) NULL,
  `levelId` INT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC));

# 请参考文档和环境进行修改
INSERT INTO `system_config` (`config_id`,`conf_key`,`conf_value`,`val_type`,`val_desc`,`create_time`,`sts`,`modify_time`) VALUES (1000,'mail_info','{\"mail.host\":\"mail.asiainfo.com\",\"mail.transport.protocol\":\"smtp\",\"mail.smtp.auth\":\"true\",\"mail.smtp.starttls.enable\":\"false\",\"mail.username\":\"testA\",\"mail.password\":\"******\",\"mail.account.prefix\":\"@asiainfo.com\"}','json','默认邮件发送人信息','2015-12-10 11:54:06','A','2015-12-10 11:54:06');
INSERT INTO `system_config` (`config_id`,`conf_key`,`conf_value`,`val_type`,`val_desc`,`create_time`,`sts`,`modify_time`) VALUES (1001,'portal_addr','http://10.1.235.197:48080/skywalking/','string','默认门户地址','2015-12-10 15:23:53','A','2015-12-10 15:23:53');
INSERT INTO `system_config` (`config_id`,`conf_key`,`conf_value`,`val_type`,`val_desc`,`create_time`,`sts`,`modify_time`) VALUES (1002,'servers_addr','10.1.235.197:34000;10.1.235.197:35000;','string','日志采集地址','2015-12-10 15:23:53','A','2015-12-10 15:23:53');
INSERT INTO `system_config` (`config_id`,`conf_key`,`conf_value`,`val_type`,`val_desc`,`create_time`,`sts`,`modify_time`) VALUES (1003,'servers_addr_1','XXX.XXX.XXX.XXX:34000;','string','日志采集地址-外网','2015-12-10 15:23:53','A','2015-12-10 15:23:53');



INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('1', 'buriedpoint.printf', 'false', 'false', '是否打印数据', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('2', 'buriedpoint.max_exception_stack_length', '4000', '4000', '埋点异常的最大长度', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('3', 'buriedpoint.businesskey_max_length', '300', '300', '业务字段的最大长度', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('4', 'buriedpoint.exclusive_exceptions', '$exclusiveException', '$exclusiveException', '过滤异常', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('5', 'sender.connect_percent', '100', '100', '最大发送者的连接数阀比例', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('6', 'sender.servers_addr', '#servers_addr', '#servers_addr_1', '发送服务端配置', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('7', 'sender.max_copy_num', '2', '2', '最大发送的副本数量', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('8', 'sender.max_send_length', '20000', '20000', '发送的最大长度', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('9', 'sender.retry_get_sender_wait_interval', '2000', '2000', '当没有Sender时,尝试获取sender的等待周期', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('10', 'sender.is_off', 'false', 'false', '是否开启发送消息', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('11', 'consumer.max_consumer', '2', '2', '最大消费线程数', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('12', 'consumer.max_wait_time', '5', '5', '消费者最大等待时间', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('13', 'consumer.consumer_fail_retry_wait_interval', '50', '50', '发送失败等待时间  ', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('14', 'buffer.buffer_max_size', '18000', '18000', '每个Buffer的最大个数', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('15', 'buffer.pool_size', '5', '5', 'Buffer池的最大长度', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('16', 'senderchecker.check_polling_time', '200', '200', '发送检查线程检查周期', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('18', 'skywalking.charset', 'UTF-8', 'UTF-8', 'skywalking数据编码', 'A');
INSERT INTO `test`.`auth_file_config` (`config_id`, `key`, `value0`, `value1`, `key_desc`, `sts`) VALUES ('19', 'skywalking.sdk_version', '1.0a2', '1.0a2', 'skywalking SDK的版本', 'A');

