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:

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

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 のインポートスクリプトは2種類あります。kunena.rbkunena3.rb です。Kunena 自体はバージョン 6.x まであります。より新しいバージョンの Kunena には、どちらのスクリプトを使用すべきでしょうか?

まず kunena.rb を試します。

「いいね!」 1

@JetForMe

最終的なスクリプトをgistに投稿しました。正直、そこで何をしたのか、私のコミュニティにどれほど特化しているのかは覚えていません。しかし、それらのスクリプトをオリジナルと比較して、解決した問題や追加したものをいくつか見つけることができるかもしれません。インポートをより完全なものにしようとしました。マイグレーション中に情報が失われるのは嫌なので。

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 は機能しません。