Hi @pfaffman , Please let me know if you can support . i want to import from v2.3.6 , have issues linking the topics to forum_id as this version dont have one can you please let me know which table hold the value to link between topic and forum
This is what i have for importing topics now , it can import but all topics are going to uncategorized,
def import_topics
puts "\n📌 Importing Topics..."
total_count = mysql_query("SELECT count(*) count FROM iBB_posts WHERE new_topic = 1;").first['count']
batches(BATCH_SIZE) do |offset|
discussions = mysql_query(<<-SQL
SELECT pid as tid, topic_id, post_title as title, post as raw,
FROM_UNIXTIME(post_date) as created_at, author_id
FROM iBB_posts
WHERE new_topic = 1
ORDER BY post_date ASC
LIMIT #{BATCH_SIZE} OFFSET #{offset};
SQL
).to_a
break if discussions.empty?
create_posts(discussions, total: total_count, offset: offset) do |discussion|
{
id: "topic-#{discussion['tid']}",
user_id: user_id_from_imported_user_id(discussion['author_id']) || Discourse::SYSTEM_USER_ID,
title: format_title(discussion['title']), # Ensure titles are properly formatted
raw: discussion['raw'],
created_at: discussion['created_at'],
post_number: 1
}
end
end
end
def format_title(title)
return "Untitled Topic" if title.nil? || title.strip.empty?
CGI.unescapeHTML(title)
end
def import_replies
puts "\n📌 Importing Replies..."
total_count = mysql_query("SELECT count(*) FROM iBB_posts WHERE new_topic = 0;").first['count']
batches(BATCH_SIZE) do |offset|
comments = mysql_query(<<-SQL
SELECT pid, topic_id, post as raw, FROM_UNIXTIME(post_date) as created_at, author_id
FROM iBB_posts
WHERE new_topic = 0
ORDER BY post_date ASC
LIMIT #{BATCH_SIZE} OFFSET #{offset};
SQL
).to_a
break if comments.empty?
create_posts(comments, total: total_count, offset: offset) do |comment|
topic_id = topic_lookup_from_imported_post_id("topic-#{comment['topic_id']}")
next unless topic_id
{
id: "post-#{comment['pid']}",
topic_id: topic_id,
user_id: user_id_from_imported_user_id(comment['author_id']) || Discourse::SYSTEM_USER_ID,
raw: comment['raw'],
created_at: comment['created_at']
}
end
end
end