db.sql 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # 新增 block_user 表
  2. CREATE TABLE `block_user` (
  3. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增id',
  4. `mid` INT(11) NOT NULL COMMENT '用户mid',
  5. `status` TINYINT(4) NOT NULL COMMENT '封禁状态',
  6. `ctime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  7. `mtime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  8. PRIMARY KEY (`id`),
  9. UNIQUE KEY `uk_mid` (`mid`),
  10. KEY `ix_mtime` (`mtime`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='封禁服务用户表';
  12. # 新增 block_user_detail 表 ,用户详情表,用作聚合数据用
  13. CREATE TABLE `block_user_detail` (
  14. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增id',
  15. `mid` INT(11) NOT NULL COMMENT '用户mid',
  16. `block_count` INT(11) NOT NULL COMMENT '封禁计次',
  17. `ctime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  18. `mtime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  19. PRIMARY KEY (`id`),
  20. UNIQUE KEY `uk_mid` (`mid`),
  21. KEY `ix_mtime` (`mtime`)
  22. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='封禁服务用户详情表';
  23. # 新增 block_history 表 —— 10张分表!!
  24. CREATE TABLE `block_history_[0-9]` (
  25. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增id',
  26. `mid` INT(11) NOT NULL COMMENT '用户mid',
  27. `admin_id` INT(11) NOT NULL COMMENT '管理员id',
  28. `admin_name` VARCHAR(16) NOT NULL COMMENT '管理员name',
  29. `source` TINYINT(4) NOT NULL COMMENT '封禁来源',
  30. `area` TINYINT(4) NOT NULL COMMENT '封禁业务',
  31. `reason` VARCHAR(50) NOT NULL COMMENT '封禁理由',
  32. `comment` VARCHAR(50) NOT NULL COMMENT '封禁备注',
  33. `action` TINYINT(4) NOT NULL COMMENT '操作类型',
  34. `start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '开始生效时间',
  35. `duration` INT(11) NOT NULL COMMENT '生效时长(秒)',
  36. `notify` TINYINT(4) NOT NULL COMMENT '是否通知',
  37. `ctime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  38. `mtime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  39. PRIMARY KEY (`id`),
  40. KEY `ix_mid` (`mid`),
  41. KEY `ix_action` (`action`),
  42. KEY `ix_mtime` (`mtime`)
  43. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='封禁服务用户历史表';
  44. # 新增 block_extra 表 封禁业务标识
  45. CREATE TABLE `block_extra` (
  46. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增id',
  47. `mid` INT(11) NOT NULL COMMENT '用户mid',
  48. `credit_answer_flag` TINYINT(4) NOT NULL COMMENT '小黑屋答题标识',
  49. `action_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '行为发生时间',
  50. `ctime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  51. `mtime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  52. PRIMARY KEY (`id`),
  53. UNIQUE KEY `uk_mid` (`mid`),
  54. KEY `ix_mtime` (`mtime`)
  55. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='封禁业务标识';