db.sql 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. CREATE TABLE keywords(
  2. id INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT COMMENT '主键id',
  3. area INT(11) NOT NULL DEFAULT 0 COMMENT '业务类型',
  4. sender_id INT(11) NOT NULL DEFAULT 0 COMMENT '发送者的id',
  5. content VARCHAR(40) NOT NULL COMMENT '关键字内容',
  6. regexp_name VARCHAR(40) NOT NULL COMMENT '该关键字命中正则名称',
  7. regexp_content VARCHAR(500) NOT NULL COMMENT '正则内容',
  8. tag tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:limit, 1:restrict, 2: whitelist, 3: blacklist',
  9. hit_counts INT(11) NOT NULL DEFAULT 0 COMMENT '命中关键字次数',
  10. state tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:default, 1:deleted',
  11. origin_content VARCHAR(1500) NOT NULL COMMENT '过滤前的内容',
  12. `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  13. `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  14. UNIQUE KEY `uk_area_content` (`area`, `content`),
  15. KEY `ix_mtime` (`mtime`),
  16. KEY `ix_area_state_ctime` (`area`,`state`, `ctime`)
  17. )ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='过滤限制关键字表';
  18. CREATE TABLE regexps(
  19. id INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT COMMENT '主键id',
  20. name VARCHAR(20) NOT NULL COMMENT 'name',
  21. area INT(11) NOT NULL DEFAULT 0 COMMENT '业务类型 1: reply, 2: imessage',
  22. operation tinyint(4) NOT NULL DEFAULT 0 COMMENT '0: limit, 1: put into whitelist, 2: restrict limit, 3: ignore',
  23. content VARCHAR(200) NOT NULL comment '正则内容',
  24. state tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:default, 1:deleted',
  25. `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  26. `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  27. KEY `ix_mtime` (`mtime`),
  28. UNIQUE KEY `uk_area_content` (`area`, `content`)
  29. )ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='过滤限制正则表';
  30. CREATE TABLE rate_limit_rules(
  31. id INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT COMMENT '主键id',
  32. area INT(11) NOT NULL DEFAULT 0 COMMENT '业务类型',
  33. limit_type tinyint(4) NOT NULL DEFAULT 0 COMMENT '0: default, 1: strict',
  34. limit_scope tinyint(4) NOT NULL DEFAULT 0 COMMENT '0: local, 1: global',
  35. dur_sec int(11) NOT NULL DEFAULT 0 COMMENT '持续时间',
  36. allowed_counts int(11) NOT NULL DEFAULT 0 COMMENT '允许发送次数',
  37. state tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:default, 1:deleted',
  38. `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  39. `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  40. KEY `ix_mtime` (`mtime`)
  41. )ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='频率规则表';
  42. CREATE UNIQUE INDEX uk_area_limit_type_limit_scope ON rate_limit_rules (area, limit_type, limit_scope);