合并两个Ucenter

注意:本文最后更新于 2595 天前,有关的内容可能已经发生变化,请参考使用。

情况是这样的:因为一些历史原因,网站使用了两个互不相关的Ucenter,一个库名为Ucenter版本是1.0,给UCHome使用,另一个库名是Ucenter2版本为1.5,给Discuz! 7.2和Supersite以及X-Spaces使用,现在因为要将所有的应用都升级到Discuz X 1.5,所以需要先将两个Ucenter合并,再进行升级工作。

大概流程:将UChome 1.0升级到1.5使之版本相同,由于Ucenter2更大故以Ucenter2为合并后的主Ucenter程序,记录下此时Ucenter2的最大用户uid(这里是169327),由于检测到Ucenter和Ucenter2中有少量重名用户,(暂无法判断是否为同一用户),于是先在Ucenter中重复用户名后添加_home以做标记:

首先解决重名问题

    //SELECT a.`username` FROM `ucenter2`.uc_members a, `ucenter`.uc_members t WHERE a.`username` = t.`username`;
        
    //update `ucenter`.uc_members set username=concat(username,+'_home') where (`ucenter`.uc_members.username) in (select username from `ucenter2`.uc_members);
        
    //update `ucenter`.uc_members set username=concat(username,+'_home') where (`ucenter`.uc_members.username) in (SELECT a.`username` FROM `ucenter2`.uc_members a, `ucenter_bak`.uc_members t WHERE a.`username` = t.`username`);
        
    //SELECT 'uid' FROM  `ucenter2`.uc_members WHERE `ucenter2`.uc_members.uid in (SELECT `ucenter2`.uc_members.uid FROM `ucenter2`.uc_members GROUP BY `ucenter2`.uc_members.uid HAVING count(`ucenter2`.uc_members.uid) >1);
        
    //create table `ucenter2`.tmptable as (SELECT `ucenter2`.uc_members.username FROM `ucenter2`.uc_members GROUP BY `ucenter2`.uc_members.username HAVING count(``ucenter2`.uc_members.username) >1);
        
     
        
    create table `ucenter2`.tmptable as (SELECT a.`username` FROM `ucenter2`.uc_members a, `ucenter`.uc_members t WHERE a.`username` = t.`username`);
        
    update `ucenter`.uc_members set username=concat(username,+'_home') where exists (SELECT username FROM `ucenter2`.tmptable where `ucenter2`.tmptable.username = `ucenter`.uc_members.username);

接下来修改Ucenter中与uid有关的部分,在原来Uid的基础上加上Ucenter2中Uid的最大值(这里是169327):

    //修改次ucenter的uid号码
        
    update `ucenter`.uc_friends set uid=uid+169327,friendid=friendid+169327,version=version+10555 ;
        
    update `ucenter`.uc_members set uid=uid+169327 ;

完成Ucenter中的相关修改后将ucenter数据导入Ucenter2中


    //将次ucenter导入主ucenter2中
        
    //insert ignore into ucenter2.uc_members select * from ucenter_gbk.uc_members;
        
    insert into ucenter2.uc_members select * from `ucenter`.uc_members;
        
    insert into `ucenter2`.uc_friends select * from `ucenter`.uc_friends;

接下来修改Uchome中与Uid有关的部分


    //修改uchome中的uid
        
    update `uchome_gbk`.uch_member set uid=uid+169327;
        
    update `uchome_gbk`.uch_userappfield set uid=uid+169327;
        
    update `uchome_gbk`.uch_blogfield set uid=uid+169327;
        
    update `uchome_gbk`.uch_space set uid=uid+169327;
        
    update `uchome_gbk`.uch_comment set uid=uid+169327,authorid=authorid+169327;
        
    update `uchome_gbk`.uch_spacefield set uid=uid+169327;
        
    update `uchome_gbk`.uch_blog set uid=uid+169327;
        
    update `uchome_gbk`.uch_pic set uid=uid+169327;
        
    update `uchome_gbk`.uch_friend set uid=uid+169327,fuid=fuid+169327;
        
    update `uchome_gbk`.uch_spaceinfo set uid=uid+169327;
        
    update `uchome_gbk`.uch_tagspace set uid=uid+169327;
        
    update `uchome_gbk`.uch_poke set uid=uid+169327,fromuid=fromuid+169327;
        
    update `uchome_gbk`.uch_post set uid=uid+169327;
        
    update `uchome_gbk`.uch_feed set uid=uid+169327;
        
    update `uchome_gbk`.uch_creditlog set uid=uid+169327;
        
     
        
    update `uchome_gbk`.uch_notification set uid=uid+169327;
        
    update `uchome_gbk`.uch_tag set uid=uid+169327;
        
    update `uchome_gbk`.uch_vote set user_id=user_id+169327;
        
    update `uchome_gbk`.uch_doing set uid=uid+169327;
        
    update `uchome_gbk`.uch_share set uid=uid+169327;
        
     
        
    update `uchome_gbk`.uch_sheep set uid=uid+169327;
        
    update `uchome_gbk`.uch_stockmarket set UserID=UserID+169327;
        
    update `uchome_gbk`.uch_thread set uid=uid+169327;
        
     
        
    update `uchome_gbk`.uch_docomment set uid=uid+169327;
        
    update `uchome_gbk`.uch_stock_wealthlist set uid=uid+169327;
        
    update `uchome_gbk`.uch_album set uid=uid+169327;
        
    update `uchome_gbk`.uch_usertask set uid=uid+169327;
        
    update `uchome_gbk`.uch_visitor set uid=uid+169327,vuid=vuid+169327;
        
     
        
    update `uchome_gbk`.uch_class set uid=uid+169327;
        
    update `uchome_gbk`.uch_userapp set uid=uid+169327;
        
    update `uchome_gbk`.uch_magicinlog set uid=uid+169327;
        
    update `uchome_gbk`.uch_invite set uid=uid+169327;
        
    update `uchome_gbk`.uch_magicuselog set uid=uid+169327;
        
    update `uchome_gbk`.uch_im_config set uid=uid+169327;
        
    update `uchome_gbk`.uch_clickuser set uid=uid+169327;
        
    update `uchome_gbk`.uch_usermagic set uid=uid+169327;
        
     
        
    update `uchome_gbk`.uch_poll set uid=uid+169327;
        
    update `uchome_gbk`.uch_eventinvite set uid=uid+169327;
        
    update `uchome_gbk`.uch_mtaginvite set uid=uid+169327,fromuid=fromuid+169327;
        
    update `uchome_gbk`.uch_userevent set uid=uid+169327;
        
    update `uchome_gbk`.uch_show set uid=uid+169327;
        
     
        
    update `uchome_gbk`.uch_spacelog set uid=uid+169327;
        
    update `uchome_gbk`.uch_event set uid=uid+169327;
        
    update `uchome_gbk`.uch_topicuser set uid=uid+169327;
        
    update `uchome_gbk`.uch_show set uid=uid+169327;
        
    update `uchome_gbk`.uch_show set uid=uid+169327;

至此两个Ucenter的合并就基本完成了,经过测试此时uchome和Discuzx 7.2、Supersite、X-Space已经可以互通,唯一的缺陷是原来Ucenter中的用户头像可能会丢失。

接下来可以用Discuz官方提供的所有版本升级到Discuz X 1.5程序将所有数据导入到Discuz x1.5,其实官方提供的所谓升级工具只是一个数据转换工具,转换之后很多原来应用中的特性都会丢失,比如X-Space的用户附件空间、文件空间等,所以请用到的TX请注意这一点。

待升级到Discuzx 1.5完成之后,可以通过以下方法合并之前账户名重复的帐号

原账号:Holmesian

UID:7791

计划合并账号:Holmesan_home

UID:188785


    UPDATE `ecjtu_discuzx`.`ecjtu_home_friend` SET fuid = '7791' where fuid='188785';
        
    UPDATE `ecjtu_discuzx`.`ecjtu_home_friend` SET uid = '7791' where uid='188785';
        
    UPDATE `ecjtu_discuzx`.`ecjtu_home_blog` SET uid= '7791' where uid='188785';
        
    UPDATE `ecjtu_discuzx`.`ecjtu_home_blogfield` SET uid = '7791' where uid='188785';

「倘若有所帮助,不妨酌情赞赏!」

Holmesian

感谢您的支持!

使用微信扫描二维码完成支付


相关文章

发表新评论