We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How to migrate an ubbthreads community to Oxwall | Forum

Julien
Julien Apr 9 '14
Hi,

I am wondering if there is some kind of information available on how best to migrate an existing ubb threads community to oxwall. I am handy with SQL and PHP, so I can write some SQL scripts to export data from ubb to oxwall. I want to use the oxx forums as a replacement from the ubb threads forum, so I am interested in any insights upon the oxx database structure that I can use.

E.g. are there any basic SQL scripts available for the following:
-Create forum.
-Create topic in Forum
-Add post to forum.

I also want to migrate my userbase, so I am also interested in any basic SQL scripts to:
-Create a user and set password to something.

Any help would be appreciated with this :).
Julien
Julien Apr 9 '14
P.s. I found the csv importer, so first I am going to figure out if I can export my data to a csv format.
ross Team
ross Apr 11 '14
if you want to transfer only base user information, like username, e-mail, age, without any content,  you can use this plugin: http://www.oxwall.org/store/item/40 otherwiser you'll need to write a migration script. 


You can export your user table via phpmyadmin, don't forget to choose csv format

Julien
Julien Apr 11 '14
I think I need to write a migration script. I am trying to find out how the csv importer needs its data and which columms it expects. Unfortunately there is not much documentation about this, so I am digging into the code now. Will share my code here for everyone else.

The most important part for me is, the forum content actually so any help on this is really appreciated!
Julien
Julien Apr 11 '14
Here is a first part of the import script. It works by creating some views in the UBB threads database that mimics the oxwall's database. The first script is for basic user information like loginname etc. When this view is there, export the data to a csv, and import it into the correct ox-table (ow_base_user):

CREATE
    OR REPLACE
    VIEW ow_base_user
AS
select us.user_id as id, up.USER_REAL_EMAIL as amail, us.USER_LOGIN_NAME as username,
'eec5892b972074da21a61e6caf64691ce7dbff264c09ed233da34e67bab8d1d4' as password,
'1397252792' as joinStamp,
'1397252792' as activityStamp,
'290365aadde35a97f11207ca7e4279cc' as accountType,
1 as emailVerify,
0 as joinIp
from
ubbt_USERS AS us
INNER JOIN ubbt_USER_PROFILE AS up ON us.USER_ID = up.USER_ID
where us.user_id > 1
The Forum post is edited by Julien Apr 11 '14
Julien
Julien Apr 11 '14
And another step to enrich the newly created profile with their display name and birthday (if entered).

Export and import from "ow_base_question_data"

CREATE
    OR REPLACE
    VIEW ow_base_question_data
AS

select null as id,
'realname' as questionName,
us.user_id as userId,
us.USER_DISPLAY_NAME as textValue,
0 as intValue,
null as dateValue
from
ubbt_USERS AS us
INNER JOIN ubbt_USER_PROFILE AS up ON us.USER_ID = up.USER_ID
where us.user_id > 1

union
select null as id,
'birthdate' as questionName,
us.user_id as userId,
null as textValue,
0 as intValue,
STR_TO_DATE(up.USER_BIRTHDAY, '%c/%e/%Y %H:%i') as dateValue
from
ubbt_USERS AS us
INNER JOIN ubbt_USER_PROFILE AS up ON us.USER_ID = up.USER_ID
where us.user_id > 1 and up.USER_BIRTHDAY <> 0

Julien
Julien Apr 12 '14
And here to add the forum categories:

CREATE
    OR REPLACE
    VIEW ow_forum_section
AS
Select
CATEGORY_ID as id,
CATEGORY_TITLE as name,
CATEGORY_SORT_ORDER as 'order',
null as entity,
0 as isHidden
from ubbt_CATEGORIES
Julien
Julien Apr 12 '14
This will create your forums:

CREATE
    OR REPLACE
    VIEW ow_forum_group
AS
Select
FORUM_ID as id,    
CATEGORY_ID as sectionId,
FORUM_TITLE as name,    
FORUM_DESCRIPTION as description,
FORUM_SORT_ORDER as 'order',
NULL as entityId,
0 as isPrivate,
NULL as roles

from ubbt_FORUMS
Julien
Julien Apr 12 '14
This will create your topics:

CREATE
    OR REPLACE
    VIEW ow_forum_topic
AS
Select
TOPIC_ID as id,
FORUM_ID as groupId,
USER_ID as userId,   
TOPIC_SUBJECT as title,   
CASE WHEN TOPIC_STATUS ='C' THEN 1 ELSE 0 END as locked,    
TOPIC_IS_STICKY as sticky,   
0 as temp,   
TOPIC_VIEWS as viewCount,
TOPIC_LAST_POST_ID as lastPostId
from ubbt_TOPICS
Julien
Julien Apr 12 '14
And last, but not least, the posts themselves:

CREATE
    OR REPLACE
    VIEW ow_forum_post
AS
Select
POST_ID as id,
TOPIC_ID as topicId,
USER_ID as userId,
POST_BODY as 'text',
POST_POSTED_TIME  as createStamp
from ubbt_POSTS

And then your done! :).
Julien
Julien Apr 13 '14
This is something I found out after migration. Nobody could do anything without permissions. So this quick fix, assigns everybody to the "member" group:

CREATE
    OR REPLACE
    VIEW ow_base_authorization_user_role
AS
select
null as id,
us.user_id as userId,
12 as roleId
from
ubbt_USERS AS us
where us.user_id > 1

ross Team
ross Apr 13 '14
Topic was moved from General Questions.
Julien
Julien Apr 14 '14
Great! Oh and if everyone asks why each query has
where us.user_id > 1

This is to avoid you will override the admin user :).

One note though I noticed. Make sure your amin user does not have an username that is already there on the old forum, because when you import, you will become that new user and the administrator is not usable anymore. Solution I had was renaming the username of the new user in the database, so the old one still works.