# Issues while migrating from Kunena

**URL:** https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859
**Category:** Migration
**Tags:** kunena
**Created:** [February 5, 2015, 10:42am UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859 "2015-02-05T10:42:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 1, 2015, 3:20pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/1 "2015-02-01T15:20:55Z")

</div>

Hi all,

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.

Cheers all,

Dave

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 1, 2015, 4:47pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/2 "2015-02-01T16:47:33Z")

</div>

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.

Does that make sense?

the 2 boards are:

[http://aircadetcentral.net/acc-clone](http://aircadetcentral.net/acc-clone)  
[http://acc.maia-internet.com](http://acc.maia-internet.com)

_edit_

ok, so I cloned the main site and re-arranged the categories and they import fine now.

Howerver the posts still don’t import. What am I missing???

```
creating topics and posts
        2 / 23143 ( 0.0%) Parent post 2 doesn't exist. Skipping 4: The new mess
        3 / 23143 ( 0.0%) Parent post 0 doesn't exist. Skipping 5: Moderator Help!
        4 / 23143 ( 0.0%) Parent post 0 doesn't exist. Skipping 6: Back End Login
        5 / 23143 ( 0.0%) Parent post 0 doesn't exist. Skipping 7: Article creators

```

cheers

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 4, 2015, 5:21am UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/3 "2015-02-04T05:21:11Z")

</div>

All,

from the debugging i’ve done - and i’m not sure if i’m right, the problem lies with this line:

```
<127> parent = topic_lookup_from_imported_post_id(m['parent'])

```

it’s returning a null value for parent therefore the script doesn’t create any posts as it doesn’t know where to put it!

suggestions please!

cheers

Dave

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 4, 2015, 8:47am UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/4 "2015-02-04T08:47:17Z")

</div>

> [@Migrate from another forum to Discourse](https://meta.discourse.org/t/migrate-from-another-forum-to-discourse/16616/24):
>
> Main Cat \> Sub Cat \> Sub Sub Cat

Discourse supports only one level of subcategories.  
As a workaround I suggest you rearrange your categories in your old forum before doing the import.

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 4, 2015, 3:21pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/5 "2015-02-04T15:21:57Z")

</div>

Hi Gerhard,

Yes, I found that, as stated above. The categories now import fine, it’s the posts that aren’t being imported!

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 4, 2015, 3:57pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/6 "2015-02-04T15:57:11Z")

</div>

Ah, sorry, I should have read your whole post. 😉

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.

> <https://github.com/discourse/discourse/blob/main/script/import_scripts/kunena.rb#L96-L107>

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.

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 4, 2015, 7:01pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/7 "2015-02-04T19:01:56Z")

</div>

Hi Gerhard,

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.

Thanks for your help 😄

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 4, 2015, 10:00pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/8 "2015-02-04T22:00:22Z")

</div>

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:

```
id thread parent catid userid subject time message 	
2 2 0 2 717 The new mess 1350613779 	
3 3 0 3 717 The Crew Room 1350937488 
4 2 2 2 718 The new mess 1350938408 	
5 4 0 2 717 Moderator Help! 1350939426 	
6 5 0 2 717 Back End Login 1350939575 	
7 6 0 2 717 Article creators 1350941108
8 6 7 2 721 Article creators 1350942433 	
9 6 8 2 717 Article creators 1350942649
10 6 9 2 720 Article creators 1350942806 
12 6 7 2 717 Article creators 1350943114 
13 6 12 2 721 Article creators 1350943209
14 4 5 2 721 Moderator Help! 1350943410
15 6 12 2 717 Article creators 1350943428
16 6 15 2 721 Article creators 1350943550
17 6 16 2 717 Article creators 1350943618
18 4 14 2 717 Moderator Help! 1350943656
19 7 0 2 717 Avatars 1350944230 
20 6 7 2 720 Article creators 1350944408 
21 2 4 2 723 The new mess 1350979104 
22 2 21 2 717 The new mess 1350979893 
23 2 22 2 717 The new mess 1351001556 
24 7 19 2 717 Avatars 1351001703 	
25 2 23 2 717 The new mess 1351002874 
26 8 0 16 717 Acceptable Useage Policy 1351006949 
27 9 0 17 717 ACC BETA 1351114404 	

```

the first 2 threads get imported - sort of! but the rest all fail hmmm

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 4, 2015, 10:23pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/9 "2015-02-04T22:23:13Z")

</div>

Just by looking at it I’d say change line 123 to the following:

```ruby
if m['parent'] == 0

```

I’m not sure if `thread` is even needed. Maybe someone who knows more about kunena can chime in…

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 4, 2015, 11:09pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/10 "2015-02-04T23:09:44Z")

</div>

Wow!

It’s importing! Let’s see what the results are! … 😄

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 5, 2015, 5:37pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/11 "2015-02-05T17:37:21Z")

</div>

Well,

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?

cheers and thanks for everyone’s help

Dave

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 5, 2015, 7:03pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/12 "2015-02-05T19:03:56Z")

</div>

> [@maia\_internet](#):
>
> 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?

@neil Can you please take a look at this? For which version did you write the original importer?

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [February 5, 2015, 7:57pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/13 "2015-02-05T19:57:09Z")

</div>

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:

1. Instead of updating the existing kunena.rb, submit a new file called something like kunena3.rb.
2. 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:

```ruby
if KUNENA_VERSION == 3.0
  # do stuff for 3.0
else
  # do stuff for whatever version Neil worked on
end

```

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [February 5, 2015, 10:41pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/14 "2015-02-05T22:41:32Z")

</div>

Thanks @neil I reckon a script for kunena 3 might be the way forward. How do I go about submitting the file?

cheers

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [February 5, 2015, 10:58pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/15 "2015-02-05T22:58:21Z")

</div>

Ok that sounds good. [Submit it in a pull request](https://github.com/discourse/discourse/pulls). 😄

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [March 27, 2015, 2:32pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/16 "2015-03-27T14:32:38Z")

</div>

Hi guys,

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).

Your help please 😄

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [August 10, 2015, 1:54pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/17 "2015-08-10T13:54:34Z")

</div>

Hi again guys,

here’s the next hurdle to migrating - Private Messages.

Is there a (easy) way of migrating form Uddeim to Discourse?

Cheers

---

<div class="post-metadata">

### Author: ![maia\_internet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maia_internet/32/122258_2.png) [@maia\_internet](https://meta.discourse.org/u/maia_internet)
#### Post date: [August 21, 2015, 6:27am UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/18 "2015-08-21T06:27:25Z")

</div>

Hi @neil @gerhard @Benninger ,

I submitted a pull request and had it merged yesterday for kunena3.rb I finally got it to work for kunena 3+ installs!

It even works running against an exiting import that updates the new from the old.

Hope this helps others out as well.

Cheers

Dave

---

<div class="post-metadata">

### Author: ![Kohhal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kohhal/32/61548_2.png) [@Kohhal](https://meta.discourse.org/u/Kohhal)
#### Post date: [March 7, 2016, 4:10pm UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/19 "2016-03-07T16:10:46Z")

</div>

Hi guys,

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.

TIA!

/Kohhal

---

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [May 6, 2016, 4:13am UTC](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859/20 "2016-05-06T04:13:34Z")

</div>

@maia_internet Thank you. This worked amazing!

@Kohhal: What is the issue? It would be more useful for you to articulate what the error is rather than leave it for us to guess.

tarek : )

[Next page](https://meta.discourse.org/t/issues-while-migrating-from-kunena/24859.md?page=2)
