大型 Drupal 论坛迁移,导入器错误和限制

嗯,看起来这给我带来了麻烦。由于 postprocess_posts 函数会用新的 Discourse URL 替换旧的内部链接,我在代码中为我的导入器创建的 Wayback Machine 上的旧 Drupal 投票链接 https://web.archive.org/web/20230101093741/https://MyOldForum.com/node/98765 做了一个例外。但显然出了问题,因为我在生产迁移的站点上注意到链接变成了 https://web.archive.org/web/20230101093741/https://MyOldForum.com/t/-/12345

所以现在我不再处于迁移容器的上下文中了,原始的 Drupal 节点 nid 是否仍然可以在 Discourse 主题数据库表中找到?如果是的话,似乎可以在 Rails 控制台中对所有包含“View this poll on the Wayback Machine”的第一篇帖子进行字符串替换,然后将
https://web.archive.org/web/20230101093741/https://MyOldForum.com/t/-/[01234567890]*
替换为
https://web.archive.org/web/20230101093741/http://MyOldForum.com/node/$original_nid

这是我原来的投票导入函数:

    def import_poll_topics
    puts '', "importing poll topics"

    polls = mysql_query(<<-SQL
      SELECT n.nid nid, n.title title, n.uid uid, n.created created, n.sticky sticky, taxonomy_index.tid tid, node_counter.totalcount views
        FROM node n
        LEFT JOIN taxonomy_index ON n.nid = taxonomy_index.nid
        LEFT JOIN node_counter ON n.nid = node_counter.nid
       WHERE n.type = 'poll'
         AND n.status = 1
    SQL
    ).to_a

    create_posts(polls) do |topic|
      {
        id: "nid:#{topic['nid']}",
        user_id: user_id_from_imported_user_id(topic['uid']) || -1,
        category: category_id_from_imported_category_id(topic['tid']),
        # Use TEMPmyoldforum.com or else postprocess_posts() will try to convert the Wayback Machine /node/YYY link
        raw: "### View this poll on the Wayback Machine:\n**https://web.archive.org/web/20230101093741/http://TEMPmyoldforum.com/node/#{topic['nid']}**",
        created_at: Time.zone.at(topic['created']),
        pinned_at: topic['sticky'].to_i == 1 ? Time.zone.at(topic['created']) : nil,
        title: topic['title'].try(:strip),
        views: topic['views'],
        custom_fields: { import_id: "nid:#{topic['nid']}" }
      }
    end
  end