How to edit an import script on the production server?

How do you edit vanila.rb on production server directly?

I’m getting the same error and I know nothing about ruby.

Hey :wave:, if you have a standard installation, usually you would do the following:

cd /var/discourse
./launcher enter app

cd script/import_scripts

Then you can edit vanilla.rb here.

1 Like

Is there default editor? Because, nano and vim aren’t working in launcher.

You can install it using apt update && apt install nano ; this should work.

2 Likes

Welcome, Shin :slight_smile:

Just to know more about your import, are you following this guide (it uses the Vanilla script as an example)?

2 Likes

Thank you very much.

Whenever I searched on forum I found this this guide:

1 Like

Thank you very much. I had tried that earlier but for some reason it works now :smiley:

3 Likes

An alternative can be configuring an editor like Visual Studio Code to connect to the remote container and edit the files from here, right? Editing a script via a command-line tool such as nano can quickly be a painful experience.

Also, I think the files you modify will be overwritten if you rebuild your image.

I don’t quite remember how all of this works despite having made multiple migrations. :sweat_smile:

2 Likes

Yes it is quite hectic to modify files through command-line tools. It’s just that discourse has all the tools and features to power a well managed community.

I’ve migrated from several forums before but have 0 knowledge of ruby.

If it overwrites files, the only other solution is to create a plugin in dev box?

I was in exactly that same position about 12 months ago. I learned enough Ruby to modify the SMF import script to migrate a 700,000 post/8,000 user forum and I’ve been happily running Discourse since our migration in March.

So what you’re trying to do is definitely achievable and the support you’ll get here will help you reach your goal.

3 Likes

I’d like to quote this:

:slight_smile:

I also modified importers for my migrations, and I don’t know Ruby as well.

It’s not a mandatory skill at all.

Regarding how to edit the import scripts… I have edited some directly into the container when doing at least one of my migrations. That’s not a proper way to do it, so I wouldn’t recommend it, but if you’re careful not to lose your changes, that can do the trick.

3 Likes

It depends on what needs modifying. If it’s just a couple of simple changes then it should be OK. With the SMF import script I found it only did a partial job for me so I made significant modifications to it and re-ran partial imports dozens of times and full imports quite a few times too. It’s surprising what you find didn’t work quite as well as you thought when you get to compare the new forum content against the old content! I created a couple of scripts that would wipe the previous test Discourse system, install a new copy of Discourse and then start another import run using the latest version of the script.

3 Likes