Here is a summary of the discussion on using topic.destroy(id) to delete illegal content:
vikaskedia wanted to permanently delete a topic for legal reasons by running topic.destroy(id) in the Rails console. This deleted the topic but the category still counted it.
Mittineague suggested also deleting related rows in other tables that reference the topic id, though noted this is not officially supported and simpler to use the UI.
vikaskedia clarified they were not directly editing the database and were relying on Rails to handle dependencies. They linked to a post indicating this may delete dependent objects.
vikaskedia noted improvements since that old 2014 post. They explained someone posted questionable content so a soft delete doesn’t work. They understand not having delete in the UI but topic.destroy seems to call PostDestroyer to handle dependencies.
What other tables cross index the topic id?
Did you delete those rows as well?
What other tables cross index fields in those other tables?
Did you delete those rows?
rinse - repeat - until all are deleted.
IMHO it is much safer and a lot simpler to “delete” a topic using the UI than to delete it from the database.
AFAIK there is no “on delete cascade” code in Core and deleting fields from tables is not a supported practice, and hence not a Bug.