Migrate specific Xenforo content

Hi Discourse comm,

I have a lot of content from an old xenforo database that I want to import, but I don’t want to do a few things:

Ideally, I only want to import the threads and the first post from each thread, I also want to re-assign the thread starter to a different discourse forum/user account that I’ve already created. is this possible in an easy-enough way?

1 Like

just modify the SQL in the import script

        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,
               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

add AND p.post_id = t.first_post_id to the WHERE clause


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


mapped[:user_id] = xxx

where xxx is the Discourse user ID you want to assign the topics to.


@RGJ thanks for the quick response, you couldn’t happen to show me the SQL statement with the correct4 edit, ive tried including the AND p.post_id = t.first_post_id to the where clause but im getting SQL validation errors on the statment

oh and where is this import script?! thanks for spoonfeeding me i appreciate it

1 Like

Spent hours trying and got no where really, is there no paid support with discourse for this type of thing?


You could probably make a topic in marketplace.

1 Like

So I’m getting this error:

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

and in base.rb line 16 this exists:

require_relative “…/…/config/environment”

nothing in any import/migraton tutorial mentions the fact this doesn’t exist