# Vanilla Migration Issue

**URL:** https://meta.discourse.org/t/vanilla-migration-issue/51632
**Category:** Development
**Created:** [2016年十月17日 07:47 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632 "2016-10-17T07:47:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mmuyskens](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mmuyskens/32/67818_2.png) [@mmuyskens](https://meta.discourse.org/u/mmuyskens)
#### Post date: [2016年十月17日 07:47 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/1 "2016-10-17T07:47:09Z")

</div>

Not sure if this is the correct tag - however;

vanilla.rb errors out at line 240 if null date fields. Suggest if statement to replace null with 0000-00-00 00:00:00

Thanks,

Mark

---

<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: [2016年十月17日 07:54 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/2 "2016-10-17T07:54:53Z")

</div>

It depends. Sometimes it makes sense to have a null date. Do you know what the date is for?

---

<div class="post-metadata">

### Author: ![mmuyskens](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mmuyskens/32/67818_2.png) [@mmuyskens](https://meta.discourse.org/u/mmuyskens)
#### Post date: [2016年十月17日 08:41 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/3 "2016-10-17T08:41:00Z")

</div>

I’m not 100%, but It was in the Vanilla User table (I believe it was the DateInserted field). I updated each field that was a datetime type to work around the issue. There’s a total of 7 fields with this type in the Vanilla User DB;

[![](https://global.discourse-cdn.com/meta/original/4X/3/8/2/38202b7cd51f860cdfbac1797f25a8e94246a993.png) ](https://dl.dropboxusercontent.com/s/ama4xijykv6epby/Screenshot%202016-10-17%2004.45.26.png?dl=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: [2016年十月17日 08:49 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/4 "2016-10-17T08:49:57Z")

</div>

If it was the `DateInserted`, then it was definitely required. I’d rather it blow up (or skip it) rather than importing bad data.

---

<div class="post-metadata">

### Author: ![mmuyskens](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mmuyskens/32/67818_2.png) [@mmuyskens](https://meta.discourse.org/u/mmuyskens)
#### Post date: [2016年十月17日 09:09 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/5 "2016-10-17T09:09:12Z")

</div>

Hmm, maybe inserting the current timestamp in this case would be a better idea - anyways, just throwing this out as an issue really. Having the script stop and not import ANY users doesn’t really work 🙂

---

<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: [2016年十月17日 09:26 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/6 "2016-10-17T09:26:09Z")

</div>

Feel free to submit a PR 😉

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2016年十月17日 18:36 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/7 "2016-10-17T18:36:07Z")

</div>

If the problem is importing users, you might try using the DateFirstVisit field.

Maybe something like this:

```
created_at: parse_date(user[:date_inserted] || user[:date_first_visit]),

```

would work if for those users that don’t have an insert date they do have a first visit date.

Note: I’ve worked mostly with MySQL imports and don’t really understand what gets built in `parse_file`. This could be completely wrong and I have no way to test it.

---

<div class="post-metadata">

### Author: ![mmuyskens](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mmuyskens/32/67818_2.png) [@mmuyskens](https://meta.discourse.org/u/mmuyskens)
#### Post date: [2017年二月21日 23:16 UTC](https://meta.discourse.org/t/vanilla-migration-issue/51632/8 "2017-02-21T23:16:18Z")

</div>

I know i’m bumping my own thread but round 2 for me. Different database. Any input? We have no null date fields;

```
discourse@dev-app:/var/www/discourse$ RAILS_ENV=production ruby script/import_scripts/vanilla.rb /shared/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...
script/import_scripts/vanilla.rb:240:in `strptime': no implicit conversion of nil into String (TypeError)
        from script/import_scripts/vanilla.rb:240:in `parse_date'
        from script/import_scripts/vanilla.rb:101:in `block in import_users'
        from /var/www/discourse/script/import_scripts/base.rb:242:in `block in create_users'
        from /var/www/discourse/script/import_scripts/base.rb:241:in `each'
        from /var/www/discourse/script/import_scripts/base.rb:241:in `create_users'
        from script/import_scripts/vanilla.rb:87:in `import_users'
        from script/import_scripts/vanilla.rb:19:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from script/import_scripts/vanilla.rb:254:in `<main>'
discourse@dev-app:/var/www/discourse$

```
