Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Bulk delete of question threads and dependencies in PHPmyAdmin

+3 votes
1,096 views
asked Jun 2, 2011 in Q2A Core by case42

this is a follow on question to some thinking started here:

http://www.question2answer.org/qa/1200/how-to-delete-hidden-posts-from-the-database

I have a ton of question threads ( with many answers, comments, votes)  that need deleting . I would like to do this in the database..  

Please advise the dependencies that exist for the post table.. ie.. I sort of realize I can't just delete all the post rows with PHPmyAdmin and then think its done. 

Thanks much  

1 Answer

+3 votes
answered Jun 3, 2011 by gidgreen
selected Jul 3, 2015 by case42
 
Best answer

The key dependencies are (a) within qa_posts between a post and its parent (as specified by parentid), (b) between a post and its votes in qa_uservotes, (c) between a post and its index entries in qa_titlewords, qa_contentwords, qa_tagwords (from 1.4 dev preview), qa_posttags

All these dependencies should be taken care of by foreign keys - (b) and (c) with automatic cascading on delete, and (a) by a constraint on removal. So just ensure that before you delete a post, you delete any posts for which it is the parent.

After doing this, click all the 'recalculate/reindex' buttons on the 'Stats' page of the Admin panel, so that all counts, etc..., in the database are updated.

BTW, you might find it easier just to use the high-level functions in qa-app-posts.php, introduced in 1.4 beta 1, which take care of everything for you.

commented Jun 3, 2011 by case42
this is awesome help.. thanks much.. !
...