Quantcast
Channel: MyBB Community Forums - Merge System Support
Viewing all articles
Browse latest Browse all 347

Keeping threads rating mybb forums merging

$
0
0
Hi,

I want to merge two differents mybb forum. When i'm doing it, i'm losing the thread ratings of the forum I'm importing the datas : in the databse, the table mybb_threadratings does not contained it.


Is it possible to keep the rating of the different users ? Or should I do it after the merge by using personnal sql commands ?

Please, use the following on a backup database, you can't recover lost data !

Up to know, I have done the following in order to recover the thread ratings of the merged forum :

The merged forum has the prefix tempo_ and the new forum has the prefix mybb_ for the tables in database.

First copy the old table :

Code:
CREATE TABLE copie_threadratings
AS SELECT * FROM tempo_threadratings;

Add three columns to have the subject and the dateline from the merged forum and the new tid of the new forum :

Code:
ALTER TABLE `copie_threadratings` ADD `subject` varchar(120);
ALTER TABLE `copie_threadratings` ADD `new_tid` INT(10);
ALTER TABLE `copie_threadratings` ADD `username` varchar(120);
ALTER TABLE `copie_threadratings` ADD `new_uid` INT(10);
ALTER TABLE `copie_threadratings` ADD `dateline` bigint(30);

Fill the subject's column by matching theirs tid :

Code:
UPDATE copie_threadratings
   SET subject = (SELECT subject
                 FROM tempo_threads t1
                 WHERE t1.tid = copie_threadratings.tid);

Fill the username column by matching with their old uid :
Code:
UPDATE copie_threadratings
   SET username = (SELECT username
                 FROM tempo_users t2
                 WHERE t2.uid = copie_threadratings.uid);

Now it is possible to match to theirs new uid :
Code:
UPDATE copie_threadratings
   SET new_uid = (SELECT uid
                 FROM mybb_users t3
                 WHERE t3.username = copie_threadratings.username);

Same for the dateline column :

Code:
UPDATE copie_threadratings
   SET dateline = (SELECT dateline
                 FROM tempo_threads t4
                 WHERE t4.tid = copie_threadratings.tid);

Fill the new_tid column by matching the subject and dateline (using two values permits to avoid a multi-matching) :

Code:
UPDATE copie_threadratings
   SET new_tid = (SELECT tid
                 FROM mybb_threads t5
                 WHERE t5.subject = copie_threadratings.subject
                 AND t5.dateline = copie_threadratings.dateline);

Now it is possible to add these ratings to the table of thread ratings for the new forum :

Code:
INSERT INTO mybb_threadratings (`rid`, `tid`, `uid`, `rating`, `ipaddress`)
SELECT `rid`, `new_tid`, `uid`, `rating`, `ipaddress`
FROM copie_threadratings;


Now it is possible to delete the first copy :
Code:
DROP TABLE copie_threadratings;

It seems to work for me, hope this will help somebody else.

If anybody sees something wrong, feel free to correct me ;-)

Viewing all articles
Browse latest Browse all 347

Trending Articles