# \[Paid\] Need a Vanilla 2 Import tool

**URL:** https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852
**Category:** Marketplace
**Created:** [2014 年 4 月 18 日午前 4:42 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852 "2014-04-18T04:42:08Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![cosmo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cosmo/32/33624_2.png) [@cosmo](https://meta.discourse.org/u/cosmo)
#### Post date: [2014 年 8 月 26 日午後 7:47 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/41 "2014-08-26T19:47:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ashledombos](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ashledombos/32/114818_2.png) [@ashledombos](https://meta.discourse.org/u/ashledombos)
#### Post date: [2014 年 8 月 31 日午後 1:01 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/42 "2014-08-31T13:01:47Z")

</div>

😃 @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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2014 年 9 月 1 日午後 9:56 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/43 "2014-09-01T21:56:41Z")

</div>

> [@ashledombos](#):
>
> you’re simply asking a kind of table of correspondance for smileys, right?

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

---

<div class="post-metadata">

### Author: ![Kovah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kovah/32/60310_2.png) [@Kovah](https://meta.discourse.org/u/Kovah)
#### Post date: [2014 年 9 月 14 日午前 9:15 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/44 "2014-09-14T09:15:44Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![yusf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yusf/32/107924_2.png) [@yusf](https://meta.discourse.org/u/yusf)
#### Post date: [2014 年 10 月 2 日午後 8:20 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/45 "2014-10-02T20:20:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![robreed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robreed/32/36296_2.png) [@robreed](https://meta.discourse.org/u/robreed)
#### Post date: [2014 年 10 月 28 日午後 10:08 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/46 "2014-10-28T22:08:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2014 年 10 月 28 日午後 11:03 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/47 "2014-10-28T23:03:14Z")

</div>

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

Do you happen to have **no** moderator role?

---

<div class="post-metadata">

### Author: ![robreed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robreed/32/36296_2.png) [@robreed](https://meta.discourse.org/u/robreed)
#### Post date: [2014 年 10 月 29 日午前 5:21 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/48 "2014-10-29T05:21:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [2014 年 10 月 29 日午前 5:23 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/49 "2014-10-29T05:23:29Z")

</div>

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

```plaintext
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?

---

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [2014 年 10 月 29 日午前 5:40 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/50 "2014-10-29T05:40:03Z")

</div>

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: [discourse/script/import\_scripts/vanilla.rb at 898ceb41e8e7f3cda91b136676fdd3bf2bd0dc45 · discourse/discourse · GitHub](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](https://github.com/discourse/discourse/blob/898ceb41e8e7f3cda91b136676fdd3bf2bd0dc45/script/import_scripts/vanilla.rb#L59) resolved the issue and allowed me to successfully import my Vanilla forums file. I’ll send a pull request for the code modification.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2014 年 10 月 29 日午前 5:57 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/51 "2014-10-29T05:57:16Z")

</div>

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

```ruby
 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

```

---

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [2014 年 10 月 29 日午前 6:01 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/52 "2014-10-29T06:01:18Z")

</div>

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](https://github.com/discourse/discourse/blob/898ceb41e8e7f3cda91b136676fdd3bf2bd0dc45/script/import_scripts/vanilla.rb#L85) when `@use_lastest_activity_as_user_bio` is false.)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2014 年 10 月 29 日午前 7:44 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/53 "2014-10-29T07:44:04Z")

</div>

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

[https://github.com/discourse/discourse/commit/44b708215ec522e39a836918837ef88959525bac](https://github.com/discourse/discourse/commit/44b708215ec522e39a836918837ef88959525bac)

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

---

<div class="post-metadata">

### Author: ![robreed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robreed/32/36296_2.png) [@robreed](https://meta.discourse.org/u/robreed)
#### Post date: [2014 年 10 月 29 日午後 3:30 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/54 "2014-10-29T15:30:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![evanw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evanw/32/104827_2.png) [@evanw](https://meta.discourse.org/u/evanw)
#### Post date: [2014 年 10 月 29 日午後 3:49 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/55 "2014-10-29T15:49:45Z")

</div>

@robreed Hooray! Really glad to hear it worked. 😄

---

<div class="post-metadata">

### Author: ![4ZM](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/4zm/32/115276_2.png) [@4ZM](https://meta.discourse.org/u/4ZM)
#### Post date: [2014 年 12 月 15 日午前 10:41 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/56 "2014-12-15T10:41:48Z")

</div>

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: [Let admins be moderators if they don't exist by 4ZM · Pull Request #3042 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/3042)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2014 年 12 月 15 日午後 2:05 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/57 "2014-12-15T14:05:41Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![4ZM](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/4zm/32/115276_2.png) [@4ZM](https://meta.discourse.org/u/4ZM)
#### Post date: [2014 年 12 月 15 日午後 3:14 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/58 "2014-12-15T15:14:27Z")

</div>

Sure, that’s fine by me

---

<div class="post-metadata">

### Author: ![grrowl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grrowl/32/115451_2.png) [@grrowl](https://meta.discourse.org/u/grrowl)
#### Post date: [2015 年 1 月 12 日午後 10:58 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/60 "2015-01-12T22:58:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![grrowl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grrowl/32/115451_2.png) [@grrowl](https://meta.discourse.org/u/grrowl)
#### Post date: [2015 年 1 月 15 日午前 5:55 UTC](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852/61 "2015-01-15T05:55:22Z")

</div>

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?

[前のページ](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852.md?page=2)

[次のページ](https://meta.discourse.org/t/paid-need-a-vanilla-2-import-tool/14852.md?page=4)
