Is it possible to prune the database for a specific module only?

In Scheduler, there is a job called "Prune Database on 1st of Month".

In our instance, it is set to active and it does what it suppose to do: once per month, it deletes the record that were marked as "deleted=1".

But we have a specific situation in which we need to do it more frequently but only for a specific module. In other words:

- All records except records of module X: should get pruned once a month

- Record of module X: should get pruned once a week

I assume this it not possible through the admin interface, but I was wondering if it was possible to achieve this through code. Maybe by creating a cron job based on Sugar's default cron job?

Any help is appreciated. Thank you!

  • Ok, so a bit more details:

    So the goal is to prune module X's records every week. Here's how I was planning on doing it. Only for module X, i would:

    1) Create a Cron job that marks record older than 1 week as "deleted=1" using $bean->mark_deleted($id);

    2) Create a cron job that permanently deletes the records that are marked as "deleted=1"

    Step 1 is fine but I do have a question:

    I assume that $bean->mark_deleted($id) takes care of the record and all its relationships. So the record gets marked as "deleted=1" in the current table and also in all the other tables associated with the current one.

    - Am I right in assuming that?

    I started looking into step 2 and this is where it gets more complex. I would need to delete all records that are marked as "deleted=1" but only for module X.

    - Is there a way of doing this? What's important is getting all the related tables as well. Is this safe?