create_db.sql 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #初始table
  2. CREATE TABLE `up_rank` (
  3. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  4. `mid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
  5. `type` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '排行榜类型',
  6. `value` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排行榜数值,根据type不同,代表的含义不同',
  7. `generate_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '排行榜日',
  8. `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  9. `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  10. `value2` int(11) NOT NULL DEFAULT '0' COMMENT '分数2',
  11. PRIMARY KEY (`id`),
  12. UNIQUE KEY `uk_type_date` (`generate_date`,`type`),
  13. KEY `ix_mtime` (`mtime`)
  14. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Up蹿升榜'
  15. # fat uat表增加字段
  16. # 增加默认值
  17. alter table up_base_info alter column active_tid set default 0;
  18. alter table up_base_info alter column attr set default 0;
  19. alter table up_base_info alter column mid set default 0;
  20. alter table up_base_info alter column mid set default 0;
  21. alter table up_play_info alter column mid set default 0;
  22. alter table up_play_info alter column business_type set default 0;
  23. alter table up_play_info alter column article_count set default 0;
  24. alter table up_play_info alter column play_count_90day set default 0;
  25. alter table up_play_info alter column play_count_7day set default 0;
  26. alter table up_play_info alter column play_count_30day set default 0;
  27. alter table up_play_info alter column play_count_accumulate set default 0;
  28. alter table up_stats_history alter column type set default 0;
  29. alter table up_stats_history alter column sub_type set default 0;
  30. alter table up_stats_history alter column generate_date set default '0000-00-00';
  31. alter table up_rank alter column mid set default 0;
  32. alter table up_rank alter column type set default 0;
  33. alter table up_rank alter column value set default 0;
  34. alter table up_rank alter column generate_date set default '0000-00-00';
  35. alter table task_info alter column generate_date set default '0000-00-00';
  36. alter table task_info alter column task_type set default 0;
  37. alter table up_base_info add column active_tid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '最多稿件分区';
  38. alter table up_base_info add column attr int(11) NOT NULL COMMENT '属性,以位区分';
  39. alter table up_rank add column value2 int(11) NOT NULL DEFAULT 0 COMMENT '分数2';
  40. ALTER TABLE up_base_info MODIFY active_tid smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '最多稿件分区';
  41. #FAT
  42. alter table up_play_info drop column play_count_avg;
  43. alter table up_play_info drop column play_count_avg_90day;
  44. alter table up_play_info add column `article_count` int(11) NOT NULL DEFAULT '0' COMMENT '总稿件数';
  45. alter table up_play_info add column `play_count_90day` int(11) NOT NULL DEFAULT '0' COMMENT '90天内稿件总播放次数';
  46. alter table up_play_info add column `play_count_30day` int(11) NOT NULL DEFAULT '0' COMMENT '30天内稿件总播放次数';
  47. alter table up_play_info add column `play_count_7day` int(11) NOT NULL DEFAULT '0' COMMENT '7天内稿件总播放次数';
  48. #FAT UAT
  49. DROP INDEX ix_mid ON up_base_info;
  50. alter table up_base_info add unique key uk_mid_type (`mid`,`business_type`);
  51. #每天一条记录 增加分数段表, (uat 1, fat 1, prod 1)
  52. create table score_section_history(
  53. id int(11) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '自增ID',
  54. generate_date date NOT NULL COMMENT '生成日期',
  55. score_type SMALLINT(6) NOT NULL DEFAULT 0 COMMENT '类型, 1质量分,2影响分,3信用分',
  56. section_0 int(11) NOT NULL DEFAULT 0 COMMENT '0~100的人数',
  57. section_1 int(11) NOT NULL DEFAULT 0 COMMENT '101~200',
  58. section_2 int(11) NOT NULL DEFAULT 0 COMMENT '201~300',
  59. section_3 int(11) NOT NULL DEFAULT 0 COMMENT '301~400',
  60. section_4 int(11) NOT NULL DEFAULT 0 COMMENT '401~500',
  61. section_5 int(11) NOT NULL DEFAULT 0 COMMENT '501~600',
  62. section_6 int(11) NOT NULL DEFAULT 0 COMMENT '601~700',
  63. section_7 int(11) NOT NULL DEFAULT 0 COMMENT '701~800',
  64. section_8 int(11) NOT NULL DEFAULT 0 COMMENT '801~900',
  65. section_9 int(11) NOT NULL DEFAULT 0 COMMENT '901~1000',
  66. ctime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  67. mtime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  68. UNIQUE uk_date_type(generate_date, score_type),
  69. KEY ix_mtime (mtime)
  70. ) engine=innodb DEFAULT charset=utf8 comment='up分数段人数分布表';
  71. #增加信用分、影响分、质量分字段 (uat 1, fat 1, prod 1)
  72. alter table up_base_info add COLUMN credit_score INT NOT NULL DEFAULT 500 COMMENT '信用分';
  73. alter table up_base_info add COLUMN pr_score INT NOT NULL DEFAULT 0 COMMENT '影响分';
  74. alter table up_base_info add COLUMN quality_score INT NOT NULL DEFAULT 0 COMMENT '质量分';
  75. #修复key错误 (uat 1, fat 1, prod 1)
  76. DROP INDEX uk_type_date ON up_rank;
  77. alter table up_rank add unique key uk_date_type_mid (`generate_date`,`type`, `mid`);
  78. #增加生日、地域等字段 (uat 1, fat 1, prod 1)
  79. alter table up_base_info add COLUMN birthday DATE NOT NULL DEFAULT '0000-00-00' COMMENT '生日';
  80. alter table up_base_info add COLUMN active_province varchar(32) NOT NULL DEFAULT '' COMMENT '省份';
  81. alter table up_base_info add COLUMN active_city varchar(32) NOT NULL DEFAULT '' COMMENT '城市';
  82. #增加task info的unique key(uat 1, fat 1, prod 1)
  83. alter table task_info add unique key uk_date_type (`generate_date`,`task_type`);