# Reset after running migration script?

**URL:** <https://meta.discourse.org/t/reset-after-running-migration-script/281224>\
**Category:** Migration\
**Tags:** vanilla\
**Created:** [October 5, 2023, 10:29pm UTC](https://meta.discourse.org/t/reset-after-running-migration-script/281224 "2023-10-05T22:29:38Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![MikeD](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@MikeD](https://meta.discourse.org/u/MikeD)\
**Post date:** [October 5, 2023, 10:29pm UTC](https://meta.discourse.org/t/reset-after-running-migration-script/281224/1 "2023-10-05T22:29:39Z")

</div>

I’m using the migration scripts to migrate a Vanilla 3 forum to self-hosted Discourse.

The migration script is working fine:  
`RAILS_ENV=production ruby script/import_scripts/vanilla.rb /shared/uploads/export.text`

The only issue is that once I’ve done the export, I can’t seem to re-import again. The import script runs fine a second time, but any data changes I made to the import file are not applied. Also, the importer runs about 50x faster on the second run, which makes me suspect it’s not actually importing anything.

Question: is there any way to re-run the import scripts located at  
`/var/www/discourse/script/import_scripts/`  
after the first run?

Specifically, as I fix bugs in my import file format, I’d like to be able to re-import to have updates made to posts & discussions only.

So far the only solution I found was to nuke the entire Discourse install and start from scratch, which takes nearly an hour each time.

Any tips?

Here is the relevant code from vanilla.rb:

```plaintext
  def import_posts
    puts "", "importing posts..."

    create_posts(@comments) do |comment|
      next unless t = topic_lookup_from_imported_post_id("discussion#" + comment[:discussion_id])

      {
        id: "comment#" + comment[:comment_id],
        user_id:
          user_id_from_imported_user_id(comment[:insert_user_id]) || Discourse::SYSTEM_USER_ID,
        topic_id: t[:topic_id],
        raw: clean_up(comment[:body]),
        created_at: parse_date(comment[:date_inserted]),
      }
    end
  end

```

I’m a programmer but not a ruby programmer - is there any way to modify this code to force it to replace the content of a post if I do a re-import?

---

_[View the full topic](https://meta.discourse.org/t/reset-after-running-migration-script/281224)._
