Clean audit tables?

We have been using Sugar for more than 6 years. We have audit log records that go back to the start of our use of Sugar. The Archive Data tool does not have the ability to archive audit tables. What is the best practice to remove older data from these tables?

Parents
  • For Sugar Cloud, I've been asking support to run the following script, by making all intervals in MONTH units, I can then, depending on the clients desire, I do a search and replace on the number of months, i.e. 12 MONTH, or 36 MONTH...

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    -- clean out (most but not all) audit tables in SugarCRM older than x months
    -- Search and replace `12 MONTH` with timeframe you desire to keep
    DELETE FROM accounts_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE accounts_audit;
    DELETE FROM audit_events
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE audit_events;
    DELETE FROM bugs_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE bugs_audit;
    DELETE FROM business_centers_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE business_centers_audit;
    DELETE FROM calls_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Ben Hamilton (more)
Reply
  • For Sugar Cloud, I've been asking support to run the following script, by making all intervals in MONTH units, I can then, depending on the clients desire, I do a search and replace on the number of months, i.e. 12 MONTH, or 36 MONTH...

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    -- clean out (most but not all) audit tables in SugarCRM older than x months
    -- Search and replace `12 MONTH` with timeframe you desire to keep
    DELETE FROM accounts_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE accounts_audit;
    DELETE FROM audit_events
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE audit_events;
    DELETE FROM bugs_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE bugs_audit;
    DELETE FROM business_centers_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    OPTIMIZE TABLE business_centers_audit;
    DELETE FROM calls_audit
    WHERE date_created < NOW() - INTERVAL 12 MONTH;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Ben Hamilton (more)
Children
No Data