punBB to MyghtyBoard importer
From PHP to DjangoIt is possible to make quick and flexible migrations from PHP/Other sources to Django. We can use Django ORM as a data dump "format". If we do so we will get a dump that is database type indepented, and we wont have encoding problems (for non latin1 data). This article is based on older Diamanda release and the models aren't up to date.
I'll show here a punBB -> MygthyBoard migration script. First let's look at MyghtyBoard Categories model: We have to make a script, that will inserf few categories using Django ORM. Script like this one: Place it in the Django project folder and execute. This scripts have 3 parts - core modules import, models import and last - data. Now we have to use PHP or Python with mysql-python (for MySQL) to make such script. It has to get all the categories from punBB and "show" them. PunBB categories table has 3 columns: id, name and disp_position (order), so all data is there. We need to print in a loop this code:
I used PHP and punBB API to do this: Place it in punBB folder and open in a browser. It will create a "install.py" file with all the categories ready to insert into MyghtyBoard.
p = Category(name='''NAME''', order='''ORDER''') p.save()
Next one are forums. In this model we have ForeignKey: punBB table contains ID od the category entry. We have to use an object: Category.objects.get(id=ID_NUMBER). Also if our categories in punBB aren't numbered from 1 without any holes then we would also have to add original ID to the category dump. Here is the code: We used the category object. We also use the original ID for the forum entry.
The last problem is user import. Django saves user passwords like this
"sha1$SALT$HASH"Where sha1> is the has function, SALT - random string added to the password to make the HASH. punBB uses by default sha1 so there is no problems with user import. We just have to use empty salt:
"sha1$$HASZ"The migration code would look like this:
migrated data in MyghtyBoard