db.sql 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 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='封禁服务用户历史表';