Vanilla Migration Issue

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

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

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;

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

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 :slight_smile:

1 Like

Feel free to submit a PR :wink:

2 Likes

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.

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$