News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to merge two SMF Forums?

Started by Hoshi, November 22, 2004, 12:39:17 PM

Previous topic - Next topic

perplexed

Quote from: Motoko-chan on December 16, 2006, 08:25:16 PM
Quick steps to manually merge forums:

Note: pick one forum as the forum to merge to. This is the destination forum. The forum you are merging in is the source forum.


  • Find the last ID for the users on the destination. Add 1 to it. Import the source users table, adding the number to all user IDs.
  • Find the last ID for the categories. Add 1 to it. Import the source categories table, adding the number to each category ID.
Now, the difficult stuff

  • Find the last ID for the boards. Add 1 to it. Keep this in mind.
  • Find the last ID for the topics. Add 1 to it. Keep this in mind.
  • Find the last ID for the posts. Add 1 to it. Keep this in mind.
  • Find the last ID for the members. Add 1 to it. Keep this in mind.
  • Find the last ID for the polls. Add 1 to it. Keep this in mind.
  • Import the boards table. Add the appropriate numbers for the board ID, first and last message ID, parent ID if not 0, and category ID.
  • Import the topics table. Add the appropriate numbers for the topic ID, board ID, message IDs, member IDs, and poll IDs.
  • Import the messages table. Add the appropriate numbers for the message IDs, topic ID, board ID, and member IDs.
  • Import the polls table. Add the appropriate numbers for the poll IDs and member IDs.
  • Import the poll choices table. Add the appropriate numbers for the poll IDs.
  • Import the messages table. Add the appropriate numbers for the message IDs, topic ID, board ID, and member IDs.
This will get most of the system working, but you'll still be missing personal messages, themes, posts being marked as read, non-post count member groups, special permissions, secondary groups, and probably a few other things I've forgotten.

And of course, this doesn't even take into account any collisions in users or whatnot.

Supposing the member details are the same for both forums - as one was a copy of the other long time ago for testing purposes.  So all we really want is to merge all the boards, posts, topics in one forum A  into the active forum B.  The members are the same.  PMs are saved and cleared out on A, all we really want is to have the boards and posts moved to the B forum and to show the correct members as having posted them.

Would that be simpler to do?  I don't know much about sql databases :(

christicehurst

Bumping this topic to see what current ideas members have. I'm currently wanting to move posts, members, boards, PM's, and polls to a new forum.
www.brisbanelionsunited.com - A forum for everyone!

Klozi

Hi guys, any more progress on this?

metallica48423

no.

One team member was working on one awhile back but theres been no progress on it.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

bcarl314

I just wanted to post this message in this thread because this is the best indexed in google when I search for "merge smf". I was able to successfully merge posts, boards, categories, messages, and members from 2 smf forums using this method...

1) Get a database dump from one of the formums that you want to merge. Call this the "from" forum ;)

2) With that extract, make a new database. I called it "smf_2" and import that data into the database (note, you could probably just skip these first 2 steps if you in-activate the "from" forum.

3) In the "to" forum (the other one that I'm going to merge with) get the max numbers for each of the following tables...

smf_boards
smf_categories
smf_members
smf_messages
smf_topics

4) In the "from" forum, update the necessary fields in those tables. Below is the SQL I used, your mileage may vary ;)


UPDATE smf_boards SET ID_BOARD = ID_BOARD+20;
UPDATE smf_boards SET ID_LAST_MSG = ID_LAST_MSG+6000;
UPDATE smf_boards SET ID_MSG_UPDATED = ID_MSG_UPDATED+6000;
UPDATE smf_boards SET ID_CAT = ID_CAT+5;
UPDATE smf_members SET ID_MEMBER = ID_MEMBER+5000;
UPDATE smf_members SET ID_MSG_LAST_VISIT = ID_MSG_LAST_VISIT+6000;
UPDATE smf_topics SET ID_TOPIC = ID_TOPIC+2000;
UPDATE smf_topics SET ID_BOARD = ID_BOARD+20;
UPDATE smf_topics SET ID_MEMBER_STARTED = ID_MEMBER_STARTED+5000;
UPDATE smf_topics SET ID_MEMBER_UPDATED = ID_MEMBER_UPDATED+5000;
UPDATE smf_topics SET ID_FIRST_MSG = ID_FIRST_MSG+6000;
UPDATE smf_topics SET ID_LAST_MSG = ID_LAST_MSG+6000;
UPDATE smf_messages SET ID_MSG = ID_MSG+6000;
UPDATE smf_messages SET ID_TOPIC = ID_TOPIC+2000;
UPDATE smf_messages SET ID_BOARD = ID_BOARD+20;
UPDATE smf_messages SET ID_MEMBER = ID_MEMBER+5000;
UPDATE smf_messages SET ID_MSG_MODIFIED = ID_MSG_MODIFIED+6000;
UPDATE smf_categories SET ID_CAT = ID_CAT+5;


Make sure those numbers (20, 5, 5000, 6000) are greater than the numbers you got in step 3!

5) Now export the data from your "smf_2" database for each table. i.e.

mysqldump -u bcarl314 --no-create-info -p smf_2 smf_boards  > smf_boards.sql


6) Import those SQL files into your "to" database.

So far, this seems to work for me. I'll post back if I run into any problems. Note, I probably missed something here, and this is not intended as a comprehensive, one-size-fits-all approach, but it's probably a good start for most.


dakotaroar

#45
I have also just posted my merging method at this link: http://www.simplemachines.org/community/index.php?topic=188524.msg1411079#msg1411079
The only forum for students in North and South Dakota!  Campus Dakota.

MICHICAUST

I have posted a related problem in dakotaroar's thread, here:

http://www.simplemachines.org/community/index.php?topic=188524.msg1581269#msg1581269

I am linking this here to avoid double postings.. ;)


Best regards,

- Michael

NotNice

wow, this is an old topic....
and yet this is my current question, can you merge two existing SMF-forums?

I do not need to merge all of it, it is an old forum (i have a back-up) and a forum we are using on a daily basis and we would like to have all the old topics in the new forum.
The 'old' forum is not that old, I believe version SMF 2.0 R2, perhaps RC1, and the new forum is SMF 2.0 RC3

so I need to merge the topics and messages tables, and i need to change the member-id's to the new member-id's because nearly all the old members are on my new forum. Some are not but i'll just give them a guest-id or something

I intend to copy the new forum to a new location (the old location will be the back-up and we'll keep using that if the merging fails) and try the merge there.

Does anyone have any good advice?
(other than 'back-up back-up back-up because I know that one already)
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

Arantor

Firstly, perform an upgrade on the other forum; there were numerous DB changes from RC1 to RC3, though if you're on RC2 you've already got most of them.

Ultimately what you'll be doing is stepping through both sets of tables and figuring out what order the topics come in (since topics and messages are always ordered by numeric id).

Essentially what you'll be creating somewhere is a master list of topic ids from the old forum and what topic they map to in the new forum.

For example, from forum 1, topics 1, 2 and 3 might become 1, 3 and 5, while topics 1, 2, 3 from forum 2 become topics 2, 4 and 6. So you build a map of topics and messages from the old forum, so the destination gives you a single master list of topics and messages that contains only unique ids.

Then you step through and insert them according to the new map, and ensure you fix up all the ids afterwards, not only in the topic/messages tables, but any linked tables - that includes boards, calendar entries, attachments and so on.

Also note that it is a massively computational task involving multiple queries per post, multiple per topic and in all likelihood tens of thousands of queries.

NotNice

thanks a lot for the advice, this is very helpfull

on the old forum the calender was not in use and attachments were (and are) not allowed so that saves me some troubles

also, the old forum really pre-dates the new one, so I can leave the old-forum-id's as they are and change the new-forum id's to follow-up on the old ones
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

Arantor

See, I didn't know that.

Make sure to reset board ids, and also ensure user ids match up in the new environment - might want to reset that before you start.

NotNice

#51
would it be a good idea to make a new board on the new forum, set all the board-id for the old topics and assign some moderators to the noble task of sorting the stuff?
Because the old boards really do not match the new ones

I have the old and the new user-id list so I know what the old id's need to be changed to in the old messages
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

Arantor

It certainly wouldn't hurt to change the board id over to a new central dumping board. Note that board id is IIRC in both messages and topics tables.

NotNice

Thanks for that! I would probably have forgotten the topics table so you've saved me!
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

dakotaroar

The SQL code I posted a while back (waaaaay back now) goes through a lot of the logic Arantor described.  What would need to be done is to make sure all the table and field names are up to date with 2.0, which would take a little time with phpmyadmin (I would do it, but I don't have any current local installs or any time any more :().

I wish I could mess with this more for people since messing databases is quite fun, but I'm stuck in front-end development at the moment with Drupal.   :-\
The only forum for students in North and South Dakota!  Campus Dakota.

NotNice

thanks for the script! I'll let you know how it worked out :)
the table and field names match, I have some experience with mysql and phpmyadmin, but i spent most of my time making joomla-templates and fiddling in the database is not something I do every day

it's a pity you don't have the time, messing around is so much more fun when you're not doing it alone ;)

it's getting a bit confusing though, as I have an old-forum database, a new-forum database, an old-forum-adjusted/tweaking database and a old+new-merged-forum database... :D
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

SlammedDime

One of our devs has started working on a script to take care of this... it's still in early alpha stages right now and has some bugs to work out, and of course I can't give a timeline, but keep your eyes peeled. :)
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

MultiformeIngegno

RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

NotNice

that sounds great!
I have not had time to start my merging yet (work, work, ugh) so I am keeping an eye on this (between work and work that is ;) )
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little.

wynnyelle

Whoa! This is amazing. Can it bring one small forum into another forum as a sub forum, without overwriting anything? Porting the accounts over too without overwriting anything? Cause I got other small boards I'd love to clone into my big main one as a sub forum, like added to my alternate RPG areas.

Advertisement: