I’ve been experimenting with importing events via ICS into Discourse. As part of that, a lot of tags were created automatically, all starting with the prefix ics-. I’d now like to remove them in bulk.
From Rails console I can list them like this:
Tag.where("name LIKE ?", "ics-%").pluck(:name)
And I’ve tried deletion with:
Tag.where("name LIKE ?", "ics-%").destroy_all
That seems to work, but I’m not sure if this is the best / safest way in a Discourse context:
Will callbacks handle cleaning up topic_tags and counts correctly?
Should I be using destroy_all (safe but slower) vs. delete_all (faster but maybe leaves dangling rows)?
Do I need to rebuild tag counts afterwards?
Is there any admin-facing UI or rake task I should prefer over Rails console?
What’s the recommended approach for bulk-removing tags with a given prefix while keeping the database consistent?
I think the AI bot’s point was: the safest first step isn’t a Rails command at all — it’s asking on Meta so the snippet can be checked first. The tricky part is that ask.discourse.com doesn’t seem to know how long a topic should exist on Meta before it can be considered reliable. It can’t judge whether an answer has been reviewed by members with solid Rails experience — the people whose eyes you really want on a potentially destructive command.
For me, that’s a bridge I’m only just starting to cross, which is why I wanted to double-check here before running anything. Thanks for the guidance — I’ll proceed cautiously when there’s consensus