[Paid] Need a Vanilla 2 Import tool

@zogstrip any luck with media being imported from Vanilla to Discourse? Let me know. That would be awesome!

:smiley: @zogstrip it seems i misunderstood your request, in fact you’re simply asking a kind of table of correspondance for smileys, right?

If so I can try to make one.

1 Like

That’s right, I was indeed asking for some kind of mapping table between the smileys :wink:

1 Like

I just moved a smaller community from Vanilla to Discourse and with the help of this topic and everything worked like a charm. Thanks to the devs for the tool!

2 Likes

Happy to see the importer is up to date. Terriffic work @zogstrip.

1 Like

I’m wondering if the importer is known to work with Vanilla 2.1.x. If it is then I must be overlooking something because the import is failing after initially loading the various types of content (groups, users, categories, …)

The output I get is:

loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...
parsing file...
reading file...
parsing categories...
parsing comments...
parsing conversations...
parsing conversation_messages...
parsing discussions...
parsing permissions...
parsing roles...
parsing users...
parsing user_conversations...
parsing user_discussions...
parsing user_roles...

importing users...
script/import_scripts/vanilla.rb:83:in `import_users': undefined method `[]' for nil:NilClass (NoMethodError)
from script/import_scripts/vanilla.rb:19:in `execute'
from /var/www/discourse/script/import_scripts/base.rb:71:in `perform'
from script/import_scripts/vanilla.rb:255:in `<main>'

What I take from that is that.

  1. I’m getting the importer to run.
  2. I’m calling the importer on the file containing my exported data
  3. Something is breaking about the importer itself

Any help is greatly appreciated.

I exported from Vanilla 2.1 using Vanilla Porter 2.0.0.

Looks like it’s failing to find the id of the moderator role…

Do you happen to have no moderator role?

I have had no moderator role. Why would I delete a role? It seems crazy to me I never do stuff like that. I created the role and added a user for good measure and now I’m getting

loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...
parsing file...
reading file...
parsing categories...
parsing comments...
parsing conversations...
parsing conversation_messages...
parsing discussions...
parsing permissions...
parsing roles...
parsing users...
parsing user_conversations...
parsing user_discussions...
parsing user_roles...

importing users...
script/import_scripts/vanilla.rb:85:in `import_users': undefined method `reject' for nil:NilClass (NoMethodError)
	from script/import_scripts/vanilla.rb:19:in `execute'
	from /var/www/discourse/script/import_scripts/base.rb:71:in `perform'
	from script/import_scripts/vanilla.rb:255:in `<main>'

So not the same error, but… still getting hung up in what seems like about the same place.

@robreed Good timing! I’m experiencing the exact same issue right now. (I wasn’t missing a moderator role first, though.)

discourse@gauss-app:/var/www/discourse/script/import_scripts$ RAILS_ENV=production ruby vanilla.rb ~/export.txt 
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...
parsing file...
reading file...
parsing categories...
parsing comments...
parsing conversations...
parsing conversation_messages...
parsing discussions...
parsing permissions...
parsing roles...
parsing users...
parsing user_conversations...
parsing user_discussions...
parsing user_roles...

importing users...
vanilla.rb:85:in `import_users': undefined method `reject' for nil:NilClass (NoMethodError)
    from vanilla.rb:19:in `execute'
    from /var/www/discourse/script/import_scripts/base.rb:71:in `perform'
    from vanilla.rb:255:in `<main>'
discourse@gauss-app:/var/www/discourse/script/import_scripts$ 

@zogstrip Thank for your great work on the importer. Any thoughts on what’s causing this particular issue?

Alright I’ve never worked with Ruby before, but it looks like the activities table is getting skipped during the parsing routine.

I’ve confirmed that the activities table is getting identified from the text file, but then the following logic skips parsing it: https://github.com/discourse/discourse/blob/898ceb41e8e7f3cda91b136676fdd3bf2bd0dc45/script/import_scripts/vanilla.rb#L60


Update:

Ok, got it! Don’t take this an an official fix or anything, but it looks like the activities table was deliberately ignored for performance purposes in commit 898ceb41e8e7f3cda91b136676fdd3bf2bd0dc45, but @activities is still used later in the import_users method.

To work around this issue, I found that commenting out this line resolved the issue and allowed me to successfully import my Vanilla forums file. I’ll send a pull request for the code modification.

2 Likes

Instead of commenting out
useless_tables << "activities" unless @use_lastest_activity_as_user_bio
could you not
@use_lastest_activity_as_user_bio = true if ARGV.include?('use-latest-activity-as-user-bio')
so to affect

 if @use_lastest_activity_as_user_bio
last_activity = activities.select { |a| user[:user_id] == a[:activity_user_id] }.last
bio_raw = last_activity.try(:[], :story) || ""
else
bio_raw = user[:discovery_text]
end
1 Like

Yes, but I’m assuming that will replace the user’s existing bio information with their latest activity, which might not be desired. Perhaps @zogstrip could confirm, though.

(The root cause of problem appears to be a null reference on Line 85 when @use_lastest_activity_as_user_bio is false.)

Hmmm, the logic was indeed weird. I just fixed it.

https://github.com/discourse/discourse/commit/44b708215ec522e39a836918837ef88959525bac

Can you guys (@evanw & @robreed) try it out?

3 Likes

I can confirm the change in that commit works for me.

The import ran through without so much as a hiccup, and at first glance the forum with the imported data is looks nice.

It will take me a little while to poke around because I’m just getting started with discourse, but I think it’s fair to say the import was a complete success this time.

Thanks to everyone involved in this discussion, and @zogstrip and @evanw in particular. It’s a special thing to be able to take a support issue and turn it into a great experience (really the highlight of my day).

If you need anything else from me, just ask.

7 Likes

@robreed Hooray! Really glad to hear it worked. :smile:

The import still doesn’t work with our vanilla import. The problem is that the script expects to find the two groups:
“Administrator” and “Moderator”. We don’t have any moderators (and no moderator group) and the “Administrator” group is called “Administratör” (swedish translation of administrator) in our output.

Perhaps default the moderator id to the same as the admin if it doesn’t exist. Not sure how to handle the second problem though.

Hard coding the id in the script worked fine.

Creating a pull request: https://github.com/discourse/discourse/pull/3042

1 Like

I think a better solution to both these problems is to add 2 optional parameters: administrator_id and moderator_id.

That way, you’ll be able to pass in the values you want and handle both your cases :wink:

Sure, that’s fine by me

We had the same issue — roles “Super Moderators” and “Admins”. A pretty sloppy way to do it but I can’t think of a better one other than prompting the console to confirm which roles apply.

Fixed by hardcoding the role IDs on line 82.

Finally completed the import and set up Discourse, but the imported posts are grouped within the topic by UserID, not by post date, so the conversation’s completely disjointed.

Does anyone know if it’s possible to re-sort the posts with a SQL query or ruby command? Or any other way to resolve?