Merge two phorums as one
Posted by salmobytes
|
May 04, 2018 04:15PM |
Registered: 16 years ago Posts: 73 |
I want to combine two historically separate forums as one.
I think I know how to slog through this with a perl DBI script and command line sql.
Select several columns from phorum_messages, from both databases, as needed. First one then the other.
Store each message in a file whose name is the original datestamp post date. First line author_id. Second line data. Third line etc whatever else might be needed. I'd have to look more carefully at phorum_messages.
Prepare a new database as a copy of the bigger of the two originals.
Now delete * from phorum_messages (now you have phorum_users etc, as they are needed).
Make a list file names (which are same as datestamp) as a text file list sorted by date (sorted by file name, which is datestamp).
Read each such file in a loop. Bust it up into an array of values.
Insert one by one, into the new database name.
I'm probably missing something but it seems quite doable.
Is there a utility or plugin to do this without the all-day slog?
Edited 5 time(s). Last edit at 05/04/2018 06:39PM by salmobytes.
I think I know how to slog through this with a perl DBI script and command line sql.
Select several columns from phorum_messages, from both databases, as needed. First one then the other.
Store each message in a file whose name is the original datestamp post date. First line author_id. Second line data. Third line etc whatever else might be needed. I'd have to look more carefully at phorum_messages.
Prepare a new database as a copy of the bigger of the two originals.
Now delete * from phorum_messages (now you have phorum_users etc, as they are needed).
Make a list file names (which are same as datestamp) as a text file list sorted by date (sorted by file name, which is datestamp).
Read each such file in a loop. Bust it up into an array of values.
Insert one by one, into the new database name.
I'm probably missing something but it seems quite doable.
Is there a utility or plugin to do this without the all-day slog?
Edited 5 time(s). Last edit at 05/04/2018 06:39PM by salmobytes.
|
October 27, 2018 11:11AM |
Registered: 16 years ago Posts: 73 |
Get a list of thread heads from both forums sorted by date
select * from phorum_messages where parent_id = 0 and (forum_id = $x or forum_id = $y) order by datestamp;
loop through with perl dbi or its equivalent in some other language
make a hashed data structure of some kind that includes a new (blank for now) field called new_message_id;
loop through the data structures and write them to a well-formatted file, where the name of each file is the message_id
loop through the data structure inserting to a new database sorted by datestamp.
For each such insert update the data structure's new_message_id with the new one, just now retrieved from the previous insert
for each (thread head) datastructure
{
select * from phorum_messages where thread = datastructure.message_id order by datestamp;
make another hashed datastructure
for each response_structure insert into new database using new_message_id
}
That could be made to work. How badly do I want this?
Edited 1 time(s). Last edit at 10/27/2018 11:28AM by salmobytes.
select * from phorum_messages where parent_id = 0 and (forum_id = $x or forum_id = $y) order by datestamp;
loop through with perl dbi or its equivalent in some other language
make a hashed data structure of some kind that includes a new (blank for now) field called new_message_id;
loop through the data structures and write them to a well-formatted file, where the name of each file is the message_id
loop through the data structure inserting to a new database sorted by datestamp.
For each such insert update the data structure's new_message_id with the new one, just now retrieved from the previous insert
for each (thread head) datastructure
{
select * from phorum_messages where thread = datastructure.message_id order by datestamp;
make another hashed datastructure
for each response_structure insert into new database using new_message_id
}
That could be made to work. How badly do I want this?
Edited 1 time(s). Last edit at 10/27/2018 11:28AM by salmobytes.
Sorry, only registered users may post in this forum.