Stream Cleanup - remove stream notes older than 6+ months

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khopper
    Senior Member
    • Sep 2017
    • 329

    Stream Cleanup - remove stream notes older than 6+ months

    Is it possible to have the system run a cleanup on an entity (not system wide) that will remove stream notes older than X # of months old?
    I do not need to keep an indefinite history for certain entities.
    Last edited by khopper; 05-08-2019, 01:09 PM.
  • khopper
    Senior Member
    • Sep 2017
    • 329

    #2
    Would an MySQL query like this cause any issues with the CRM on the front end?

    Code:
    DELETE FROM `note` WHERE `parent_type` = 'ENTITYNAMEHERE' AND `type` IN ( 'post','update' ) AND `created_at` < DATE(NOW( ) - INTERVAL 6 MONTH) ;

    Comment

    • Andorxor
      Member
      • May 2019
      • 65

      #3
      You probable should delete the entries in note_user,note_team ,note_portal and notification too.
      Code:
      DELETE FROM
      `note_user`
      WHERE NOT `note_id`
      IN (SELECT `id` FROM `note`)
      
      DELETE FROM
      `note_team`
      WHERE NOT `note_id`
      IN (SELECT `id` FROM `note`)
      
      DELETE FROM
      `note_portal`
      WHERE NOT `note_id`
      IN (SELECT `id` FROM `note`)
      
      DELETE FROM
      `notification`
      WHERE NOT `releated_id`
      IN (SELECT `id` FROM `note`)
      AND `releated_type` = 'Note'

      Comment

      Working...