Migrate a Kunena 3 forum to Discourse

Based on this tutorial, should the host be ‘localhost’ ? I suspect/hope that is why my table is not found…

How to get the import script?

I came to step “Readying the Script for the import”

But when I go to:

cd /var/discourse/scripts/
ls -ls

I only see

4 -rwxr-xr-x 1 root root 150 Nov 11 12:32 docker-gc
4 -rwxr-xr-x 1 root root 1115 Nov 11 12:32 mk_swapfile

1 Like

I have the same question. I see them on GitHub here: https://github.com/discourse/discourse/tree/master/script/import_scripts

But I don’t see that in my Digital Ocean droplet. I feel pretty dumb, because the guides make this seem simple, so I guess I’m missing something obvious.

1 Like

Search here for #howto topics for other importers. It’s pretty much the same.

I did so before asking but I couldnt find it else I wouldnt ask…

Here’s one Importing from vBulletin 4

That link tells us to execute this line:

bundle exec ruby script/import_scripts/vbulletin.rb

We’re asking how to do that, because we don’t see a script directory. We only see a scripts directory, and it doesn’t contain the import scripts.

Those instructions say to install a development environment. If you had followed them, you’d see the import scripts.

If you want to try with a production docker container, you can enter the container and I think you’ll find it there,but that’s likely to cause other complications.

2 Likes

Thanks, I guess entering the container is the step I was missing. If I do that, then I can see the import scripts. Unfortunately I don’t have access to a Ubuntu or OS X machine, so I was really hoping to do this directly in Docker. But now I’m getting a bunch of other errors. Sigh. This was just a weekend experiment, so maybe I’ll just stop pursuing this option.

Thanks for your help. Feel free to delete these messages since they don’t really contribute to the actual conversation.

Hi all. My question is actually about the thread’s topic, Kunena, not about the vBulletin issue which hijacked this thread :slight_smile:

In the Kunena import script, has anybody tried importing the “Thank yous” that any user can give to other people’s posts? I actually think that’s an important part of the community status of people. It should translate into something in Discourse… badges? hearts? I’m not familiar with Discourse yet.

1 Like

It might make sense to import them as likes. A few importers do that and can serve as examples.

If you have a budget and need help, please see my contact information is in my profile.

2 Likes

FYI based on this howto I wrote this one:

1 Like

Hi Jay. I am working on the Import now, I have successfully done my first import with the Kunena3 script (with a Kunena4 database).

I got users, categories and posts converted, but now I want to fine-tune the process and get more information. Can you please point me to which conversion scripts you think are more complete (with the Likes or any other extras)? Thanks!

What I do is grep the import script directory for what I’m looking for.

I’ve not imported likes before. I’m unclear whether setting the like count in the post model is all that is required or whether that field gets updated some other way.

You can also look in app/models to see what’s there.

2 Likes

Thanks! My database has info about which user liked which post. I’ll have to see how that fits into Discourse (if possible), but it’s not just a count, it’s a list of user names related to individual posts.

You’ll need to look into the rails models to see how those are updated.

Probably this part of app/models/post_action.rb to update counts:

    when :like
      # 'like_score' is weighted higher for staff accounts
      score = PostAction.joins(:user)
        .where(post_id: post_id)
        .sum("CASE WHEN users.moderator OR users.admin THEN #{SiteSetting.staff_like_weight} ELSE 1 END")
      Post.where(id: post_id).update_all ["like_count = :count, like_score = :score", count: count, score: score]

and maybe I’ll try using this to actually do the “like” which is a kind of PostAction:

https://github.com/discourse/discourse/blob/master/script/import_scripts/lithium.rb#L380-L469

This is my first time even looking at Ruby code… this will be fun…

3 Likes

You can use the following method, if you don’t want to do everything with SQL like the Lithium importer does:

PostAction.act(user, post, PostActionType.types[:like])
1 Like

Thanks. It might be just my Ruby/Discourse newbieness tricking me, but it seems the Lithium importer is doing more stuff, I wonder if it is necessary? It seems to add rows both in UserActions and PostActions. And it has some extra logic to add only “missing” actions, why is that?

And if I use the method you suggest, do I still need to update Like counts, or does it take care of that? Thanks!

Calling PostAction.act should take care of all necessary stuff. The same method gets called when you like a post in the UI.

2 Likes