I’m having great fun with my first Discourse install - it’s a fab bit fo kit! I’m new to Ruby et al and looking for a spot of help with kununa.rb
I can get the script to run, having searched a lot but there is an issue with the script.
In the latest version of kunena the ‘categories’ table is different - field ‘parent’ is now called ‘parent_id’ and I’ve no idea how the older tables were setup, but when changing the field value in the kunena.rb script the categories import doesn’t work as it should.
Not knowing enough about Ruby I can’t quite figure out how the import process is working. What am I not doing?
Any help greatly appreciated, any more details needed please let me know.
Here’s what’s happening:
changed kunen.rb portion (changed ‘parent’ to ‘parent_id’)
create_categories(@client.query("SELECT id, parent_id, name, description, ordering FROM jos_kunena_categories ORDER BY parent_id, id;")) do |c|
h = {id: c['id'], name: c['name'], description: c['description'], position: c['ordering'].to_i}
if c['parent_id'].to_i > 0
parent = category_from_imported_category_id(c['parent_id'])
h[:parent_category_id] = parent.id if parent
end
h
end
and the output -
root@acc:/var/www/discourse# RAILS_ENV=production sudo -E -u discourse ruby script/import_scripts/kunena.rb
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...
fetching Joomla users data from mysql
fetching Kunena user data from mysql
creating users
1464 / 1464 (100.0%)
[..list of category names...]
creating topics and posts
3 / 23141 ( 0.0%) Parent post 0 doesn't exist. Skipping 5: Moderator Help!
4 / 23141 ( 0.0%) Parent post 0 doesn't exist. Skipping 6: Back End Login
5 / 23141 ( 0.0%) Parent post 0 doesn't exist. Skipping 7: Article creators
6 / 23141 ( 0.0%) Parent post 7 doesn't exist. Skipping 8: Article creators
7 / 23141 ( 0.0%) Parent post 8 doesn't exist. Skipping 9: Article creators
8 / 23141 ( 0.0%) Parent post 9 doesn't exist. Skipping 10: Article creators
9 / 23141 ( 0.0%) Parent post 7 doesn't exist. Skipping 12: Article creators
10 / 23141 ( 0.0%) Parent post 12 doesn't exist. Skipping 13: Article creators
11 / 23141 ( 0.0%) Parent post 5 doesn't exist. Skipping 14: Moderator Help!
12 / 23141 ( 0.1%) Parent post 12 doesn't exist. Skipping 15: Article creators
13 / 23141 ( 0.1%) Parent post 15 doesn't exist. Skipping 16: Article creators
14 / 23141 ( 0.1%) Parent post 16 doesn't exist. Skipping 17: Article creators
15 / 23141 ( 0.1%) Parent post 14 doesn't exist. Skipping 18: Moderator Help!
16 / 23141 ( 0.1%) Parent post 0 doesn't exist. Skipping 19: Avatars
17 / 23141 ( 0.1%) Parent post 7 doesn't exist. Skipping 20: Article creators
21 / 23141 ( 0.1%) Parent post 19 doesn't exist. Skipping 24: Avatars
23 / 23141 ( 0.1%) Parent post 0 doesn't exist. Skipping 26: Acceptable Useage Policy
it makes the first few categories - not quite correctly then refuses to import any posts - It seems that the initial categories aren’t being created properly so it doesn’t know where to import the posts.
I think I might be a step closer!
The importer is working, i think, but my original board has too many levels of sub-category.
I have:
Main Cat > Sub Cat > Sub Sub Cat
it’s those Sub Sub Cats that aren’t being brought across right, therefore the posts aren’t getting imported - I think.
I’m not using this importer, so just a guess…
It looks like the posts are imported in the wrong order.
Take a look at your database and execute the following query.
Do you see rows where parent > id? If this is the case, the ORDER BY needs to be changed.
What are the values of id and thread of the first post in each topic? They should be the same otherwise the check in line 123 won’t work.
that line <123> was confusing me because I am indeed seeing most rows where parent > id. I’m not at my regular computer at the minute so I’ll try later today and play with the ordering.
Hmmm, on the other hand the id field is a 1 up serial nothing to do with the post/parent/thread/category - it seems. Here’s the first few lines of the MySQL output using the query in the script:
most of the posts were imported using @gerhard 's suggestion about line 123 in kunena.rb
I’m guessing that some posts didn’t get created because of the content of the post - am about to investigate
Also the script only got to 65.7% of the import - no reason given but could be an overload (there’s 23000+ posts to import) and it’s only a little test DO droplet.
On the plus side the script appears to work now. Where / who do I see about updating the kunena.rb file, or indeed adding another file for kunena v3.0.6 which is the version i’ve been working with?
I’ll find out what version of Kunena that export was from. I have no idea…
There are two options for supporting multiple versions of Kunena:
Instead of updating the existing kunena.rb, submit a new file called something like kunena3.rb.
If there are only a few changes to support 3.0, then put a version constant at the top, like KUNENA_VERSION = 3.0 and the script can check that when it needs to:
if KUNENA_VERSION == 3.0
# do stuff for 3.0
else
# do stuff for whatever version Neil worked on
end
still in the process of sorting out the update for the converter - they updated kunena so I still need to check that everything works.
As a side - how would one then replace the kunena forum with Discourse? In other words, in it’s simplest form, iframe discourse into a joomla frame work? - not worried about users as the import process brings them over and I have ho need for users to log into joomla (not yet anyway).
I’m struggling with getting this import script to run - if anyone out there is willing to give me a hand it would be greatly appreciated. I have 2 sites, one small and one fairly big that I would love to migrate but I’ve been hitting a brick wall with this the last few weeks.