Adding bulk categories


I’m a new Discourse user.
My installation is running fine, with no issues so far.

The type of community I am building requires a large set of categories/topics.
There’s quite a few categories I need to add and doing it manually will literally take forever.

Could someone please explain to me (in general terms) how I could add bulk categories to Discourse?

I’ve Googled and read a few topics in the Meta, but I’m still stuck and don’t know how to achieve what I need to.

Thank you for any advice or guidance,
Enjoy your day.

If you’re going to do it once, you might do it at the rails console. If you’ll need to do it frequently going forward, using the API might make more sense.

If you do a

In rails, you’ll see what the fields are. You can then do a

Category.create(title: "fun"....)

To create them. Something like that.

1 Like

Thanks Jay,

I’m still learning about web development in general.
Do you possibly have a link to a tutorial on setting up rails (without breaking Discourse on the same Server). It’s an Ubuntu 20.04 Server.

Would I need to install rails and do the process?
Or do I need to use something specific to do it on the API?

I’ve never worked on an API before. It’s actually really confusing to me.

If I’m asking too much, please tell me.
I don’t want to come across as being demanding.

Have a great evening :slight_smile:

I am in the same boat at times. I don’t know Ruby or Rails

The data for Discourse resides in a PostgreSQL database base. It seems you have root access so you just need to get root access in the Discourse container and then let your PostgreSQL knowledge be used. If you don’t know PostgreSQL then this won’t help either.

Also you can grab a backup copy of the database at the Discourse admin page, e.g.


and do some trial runs before doing it on a production site. Don’t forget to backup the production site just before doing the SQL update.

Don’t ask me for the SQL details as I have never done this either but if you are comfortable with SQL this gives you another option.

Yes I know others will totally disagree with this but it is your site and your call.

Thanks EricGT.

I’m going to need a bit of help with this.
If anyone has the patience to school me on what needs to be done, I’d appreciate it.

Thank you :slight_smile:

You’d do this at the console. You already have rails. Something like this.

cd /var/discourse
./launcher enter app 
rails c

Administrative Bulk Operations might offer some clues.