Migrate a Kunena 3 forum to Discourse

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개의 좋아요

FYI based on this howto I wrote this one:

1개의 좋아요

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개의 좋아요

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:

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

3개의 좋아요

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개의 좋아요

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개의 좋아요

I wrote a couple importers before I knew ruby. My Programming Languages professor told us in 1986 that if a job requirement was to know some language, we didn’t need to worry. He was right.

I recommend doing things the rails way rather than mucking with the database directly.

6개의 좋아요

Kunena 가져오기 스크립트는 두 가지가 있습니다. 하나는 kunena.rb이고, 다른 하나는 kunena3.rb입니다. Kunena 자체는 6.x 버전까지 지원됩니다. Kunena의 최신 버전을 사용하려면 어떤 스크립트를 사용해야 하나요?

저라면 먼저 kunena.rb를 시도해 보겠습니다.

1개의 좋아요

@JetForMe

방금 최종 스크립트를 gist로 올렸습니다. 솔직히 거기서 뭘 했는지, 그리고 내 커뮤니티에 얼마나 특화된 건지 기억이 나지 않습니다. 하지만 그 스크립트들을 원본과 diff로 비교해 보면 제가 해결한 몇 가지 문제와 추가한 내용을 볼 수 있을 것입니다. 마이그레이션 과정에서 정보를 잃는 것을 싫어하기 때문에 임포트를 더 완전하게 만들려고 노력했습니다.

→ importing-from-kunena-3-to-discourse · GitHub
그리고
→ importing-from-kunena-3-to-discourse-2 · GitHub

도움이 되길 바랍니다.

수정: 마이그레이션 중에는 Ruby 스크립트와 SQL 명령어의 혼합을 사용했다는 걸 방금 기억났습니다(실용적인 SQL 콘솔로 DBWeaver를 권장합니다). 관심 있다면 SQL 조각을 공유할 수 있습니다.

2개의 좋아요

mariadb-server와 default-mysql-client를 설치할 수 있었습니다. (libmysqlclient-dev는 더 이상 존재하지 않습니다.)
하지만 이제 다음과 같은 오류가 발생합니다:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

그렇다면 mysql 인스턴스를 어떻게 시작해야 할까요? mysql.server start 명령은 작동하지 않습니다.