论坛风格切换
  • 3168阅读
  • 4回复

[升级方案]2011.02.26支付宝升级方案提炼 [复制链接]

上一主题 下一主题
离线太史慈
 

发帖
766
金币
626
威望
556
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-06-15
— 本帖被 云天河 从 项目开发 移动到本区(2011-09-13) —
支付宝是7.5->8.0->8.3

7.5->8.0中,主表增加字段较多
8.0->8.3中,主表增加索引较多

故现在把两个升级程序中的,主表的处理都注释掉,并且把这些SQL语句单独拉了出来,以便命令行直接执行。
附件: 7.5-8.0-8.3的up.php.zip (52 K) 下载次数:14
1条评分金币+1
rickyleo 金币 +1 整理了一份80up85的,君哥请指教 哈 http://phpwind.me/117.html 2011-06-16
[url=http://www.phpwind.com]phpwind[/url]
离线太史慈

发帖
766
金币
626
威望
556
只看该作者 沙发  发表于: 2011-06-15
主表SQL语句提炼
  1. ALTER table pw_threads add column topreplays smallint(6) DEFAULT '0' NOT NULL;
  2. ALTER TABLE pw_threads ADD modelid SMALLINT( 6 ) UNSIGNED NOT NULL ;
  3. ALTER TABLE pw_threads ADD shares MEDIUMINT UNSIGNED NOT NULL DEFAULT '0';
  4. ALTER TABLE pw_threads ADD tpcstatus INT( 10 ) UNSIGNED NOT NULL ;
  5. ALTER TABLE pw_threads CHANGE anonymous anonymous tinyint(3) NOT NULL default '0' COMMENT '是否匿名帖';
  6. ALTER TABLE pw_threads CHANGE digest digest tinyint(3) NOT NULL default '0' COMMENT '精华标志(跟顶置信息类似)';
  7. ALTER TABLE pw_threads CHANGE ifcheck ifcheck tinyint(3) NOT NULL default '0' COMMENT '是否验证';
  8. ALTER TABLE pw_threads CHANGE ifhide ifhide tinyint(3) NOT NULL default '0' COMMENT '是否隐藏贴';
  9. ALTER TABLE pw_threads CHANGE ifmagic ifmagic tinyint(3) NOT NULL default '0' COMMENT '是否为魔法表情帖';
  10. ALTER TABLE pw_threads CHANGE ifmail ifmail tinyint(3) NOT NULL default '0' COMMENT '是否邮件通知有新回复';
  11. ALTER TABLE pw_threads CHANGE ifshield ifshield tinyint(3) NOT NULL default '0'  COMMENT '评分(总分数';
  12. ALTER TABLE pw_threads CHANGE ifupload ifupload tinyint(3) NOT NULL default '0' COMMENT '是否上传附件';
  13. ALTER TABLE pw_threads CHANGE locked locked tinyint(3) NOT NULL default '0' COMMENT '是否锁定';
  14. ALTER TABLE pw_threads CHANGE modelid modelid smallint(6) unsigned NOT NULL default '0';
  15. ALTER TABLE pw_threads CHANGE shares shares mediumint(8) unsigned NOT NULL default '0';
  16. ALTER TABLE pw_threads CHANGE special special tinyint(3) NOT NULL default '0' COMMENT '特殊帖';
  17. ALTER TABLE pw_threads CHANGE state state tinyint(3) NOT NULL default '0' COMMENT '帖子状态';
  18. ALTER TABLE pw_threads CHANGE topreplays topreplays smallint(6) NOT NULL default '0' COMMENT '被置顶到的版块';
  19. ALTER TABLE pw_threads CHANGE tpcstatus tpcstatus int(10) unsigned NOT NULL default '0' COMMENT '帖子状态信息';
  20. ALTER TABLE pw_threads DROP INDEX authorid;
  21. ALTER TABLE pw_threads DROP INDEX digest;
  22. ALTER TABLE pw_threads DROP INDEX lastpost;
  23. ALTER TABLE pw_threads DROP INDEX postdate;
  24. ALTER TABLE pw_threads DROP INDEX special;
  25. ALTER TABLE pw_threads DROP INDEX type;
  26. ALTER TABLE pw_threads ADD INDEX idx_authorid(authorid);
  27. ALTER TABLE pw_threads ADD INDEX idx_digest(digest);
  28. ALTER TABLE pw_threads ADD INDEX idx_fid_ifcheck_topped_lastpost(fid,ifcheck,topped,lastpost);
  29. ALTER TABLE pw_threads ADD INDEX idx_fid_type_ifcheck(fid,type,ifcheck);
  30. ALTER TABLE pw_threads ADD INDEX idx_postdate(postdate);
  31. ALTER TABLE pw_threads ADD INDEX idx_special(special);
  32. ALTER TABLE pw_tmsgs ADD overprint smallint(6) not null default 0;
  33. ALTER TABLE pw_tmsgs CHANGE ifconvert ifconvert tinyint(3) NOT NULL default '1' COMMENT '是否进行windcode转换';
  34. ALTER TABLE pw_tmsgs CHANGE ifsign ifsign tinyint(3) NOT NULL default '0' COMMENT '是否使用帖子签名或html代码。0-两者都关闭,1-使用签名,2-使用html,3-两者都使用';
  35. ALTER TABLE pw_tmsgs CHANGE ifwordsfb ifwordsfb tinyint(3) NOT NULL default '1' COMMENT '是否词语过滤';
  36. ALTER TABLE pw_tmsgs CHANGE magic magic varchar(50) NOT NULL default '' COMMENT '魔法表情相关信息';
  37. ALTER TABLE pw_memberdata ADD fans MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER follows;
  38. ALTER TABLE pw_memberdata ADD follows MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER uploadnum;
  39. ALTER table pw_memberdata add lastgrab int(10) unsigned not null default 0;
  40. ALTER table pw_memberdata ADD lastmsg INT(10) UNSIGNED DEFAULT '0' NOT NULL;
  41. ALTER TABLE pw_memberdata ADD newcomment MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL AFTER newreferto;
  42. ALTER TABLE pw_memberdata ADD newfans MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER fans;
  43. ALTER TABLE pw_memberdata ADD newreferto MEDIUMINT( 8 ) UNSIGNED NOT NULL AFTER newfans;
  44. alter table pw_memberdata add punch int(10) unsigned not null default '0';
  45. ALTER TABLE pw_memberdata DROP INDEX postnum;
  46. ALTER TABLE pw_memberdata ADD INDEX idx_postnum(postnum);
  47. ALTER TABLE pw_members DROP INDEX email;
  48. ALTER TABLE pw_members DROP INDEX username;
  49. ALTER TABLE pw_members ADD INDEX idx_email(email);
  50. ALTER TABLE pw_members ADD INDEX idx_groupid(groupid);
  51. ALTER TABLE pw_members ADD INDEX idx_username(username(UNIQUE);
  52. alter table pw_posts drop index authorid;
  53. alter table pw_posts drop index ifcheck;
  54. alter table pw_posts drop index postdate;
  55. alter table pw_posts drop index tid;
  56. alter table pw_posts add index idx_authorid(authorid);
  57. alter table pw_posts add index idx_fid(fid);
  58. alter table pw_posts add index idx_ifcheck(ifcheck);
  59. alter table pw_posts add index idx_postdate(postdate);
  60. alter table pw_posts add index idx_tid(tid,postdate);


注意:
1。有些alter语句我加了COMMENT ,而官方程序里面是没加的,不过没多大影响吧;
2。注意分表要把一些SQL语句复制多份。
3。附件基本用不到了,里面多了回滚语句,只需要把上面的SQL直接执行即可。

缺陷:
没有把83to85的语句放进去。不过看了下83to85,没什么大表语句。
[url=http://www.phpwind.com]phpwind[/url]
离线太史慈

发帖
766
金币
626
威望
556
只看该作者 板凳  发表于: 2011-06-15
高级方案
由于改表语句众多
比如针对pw_threads的alt语句就有10多条

先把8.0的pw_threads的创表语句写下来
再把8.3的pw_threads的创表语句写下来,创建成pw_threads_83
然后INSERT INTO pw_threads_83(tid,fid,subject......) VALUES (SELECT tid,fid,subject...... FROM pw_threads);
需要自己组织下语句,这样把数据插入后,再
RENAME TABLE `pw_threads` TO `pw_threads_old` ;
RENAME TABLE `pw_threads_83` TO `pw_threads` ;

好处:能避免多次alter操作,因为每次alter操作,mysql的机制也是先建表,然后复制数据。
[url=http://www.phpwind.com]phpwind[/url]
离线rickyleo

发帖
315
金币
0
威望
99
只看该作者 地板  发表于: 2011-06-16
很好 大站就这么升级吧 我整理一份80to85的 一会儿发上来
离线rickyleo

发帖
315
金币
0
威望
99
只看该作者 4楼 发表于: 2011-06-16
整理了一份80up85的,君哥请指教 哈
http://phpwind.me/117.html
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
提到某人:
选择好友
上一个 下一个