1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Soft delete all moderated posts (queries)

Discussion in 'Tips and Guides [Archive]' started by Jake Bunce, Oct 25, 2011.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can run these queries to soft delete all moderated posts. You need to change the red pieces to attribute these deletions to a user_id and username, as well as give the reason. These things are recorded in the deletion log:

    Code:
    INSERT INTO xf_deletion_log (content_type, content_id, delete_date, delete_user_id, delete_username, delete_reason)
    	SELECT content_type, content_id, UNIX_TIMESTAMP(), 1, 'admin', 'manually moved from moderation to soft delete'
    	FROM xf_moderation_queue AS mq
    	WHERE mq.content_type = 'post';
    
    DELETE
    FROM xf_moderation_queue
    WHERE content_type = 'post';
    
    UPDATE xf_post
    SET message_state = 'deleted'
    WHERE message_state = 'moderated';
    
    And here are the queries to soft delete all moderated threads:

    Code:
    INSERT INTO xf_deletion_log (content_type, content_id, delete_date, delete_user_id, delete_username, delete_reason)
    	SELECT content_type, content_id, UNIX_TIMESTAMP(), 1, 'admin', 'manually moved from moderation to soft delete'
    	FROM xf_moderation_queue AS mq
    	WHERE mq.content_type = 'thread';
    
    DELETE
    FROM xf_moderation_queue
    WHERE content_type = 'thread';
    
    UPDATE xf_thread
    SET discussion_state = 'deleted'
    WHERE discussion_state = 'moderated';
    
    You also need to run this query to reset the count in the moderator bar:

    Code:
    DELETE
    FROM xf_data_registry
    WHERE data_key = 'moderationCounts';
    
     
    GeeksChat likes this.
  2. CyclingTribe

    CyclingTribe Well-Known Member

    Perfect.

    Many thanks Jake, should come in very handy on migration day ... (y)

    Cheers,
    Shaun :D
     

Share This Page