迁移特定 Xenforo 内容

您好 Discourse 社区,

我有一个来自旧 XenForo 数据库的大量内容想要导入,但有一些事情我不想做:

理想情况下,我只想导入帖子和每个帖子的第一条回复,我还想将发帖人重新分配给我已创建的不同 Discourse 论坛/用户帐户。有没有一种相对简单的方法可以做到这一点?

1 个赞

只需修改导入脚本中的 SQL

        SELECT p.post_id id,
               t.thread_id topic_id,
               #{@prefix_as_category ? "t.prefix_id" : "t.node_id"} category_id,
               t.title title,
               t.first_post_id first_post_id,
               t.view_count,
               p.user_id user_id,
               p.message raw,
               p.post_date created_at
        FROM #{TABLE_PREFIX}post p,
             #{TABLE_PREFIX}thread t
        WHERE p.thread_id = t.thread_id
        AND p.message_state = 'visible'
        AND t.discussion_state = 'visible'
        ORDER BY p.post_date
        LIMIT #{BATCH_SIZE}" # needs OFFSET

WHERE 子句中添加 AND p.post_id = t.first_post_id

更改

mapped[:user_id] = user_id_from_imported_user_id(m["user_id"]) || -1

mapped[:user_id] = xxx

其中 xxx 是您要分配主题的 Discourse 用户 ID。

3 个赞

@RGJ 感谢您的快速回复,您能否向我展示带有正确编辑的 SQL 语句,我尝试将 AND p.post_id = t.first_post_id 包含到 where 子句中,但我在语句中遇到了 SQL 验证错误。

哦,还有这个导入脚本在哪里?!感谢您的耐心指导,我非常感激。

1 个赞

花了几个小时尝试,但真的毫无进展,难道 Discourse 没有针对这类问题的付费支持吗?

2 个赞

你也许可以在 Marketplace 中创建一个主题。

1 个赞

我遇到了这个错误:

cannot load such file -- /var/discourse/config/environment

并且 base.rb 的第 16 行有:

require_relative "../../config/environment"

没有任何导入/迁移教程提到这个不存在。