Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.5k views
in Q2A Core by

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
by
selected by
 
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.

by
this is awesome help.. thanks much.. !
...