flipper1136
flipper1136

Reputation: 21

How to clean up snapshots and commits after a period of time in Javers?

I'm setting a auditing system for our application. The tables grow very fast. So I wonder, if there is a mechanism to clean up snapshots and commits after a period of time, for example all snapshots older than 30 days. If it is not possible, could you please suggest other approaches? Thanks.

Upvotes: 2

Views: 1033

Answers (2)

user6328124
user6328124

Reputation: 29

Clean up can be done in the following order:

  • DELETE FROM jv_commit_property;
  • DELETE FROM jv_snapshot;
  • DELETE FROM jv_commit;
  • DELETE FROM jv_global_id WHERE owner_id_fk IS NOT NULL;
  • DELETE FROM jv_global_id;

Note : You can put the filter clause as per your need which is not considered in the above DB Script.

Upvotes: 1

m.antkowicz
m.antkowicz

Reputation: 13571

I don't think that Javers provides you any mechanism to delete/update existing commits/snapshots, however you can create your own stored database household procedure and call it by some cron scheduled job. Basically you need only to filter out all JV_COMMIT entries by date (older than 30 days), then by commit id you can find properties and snapshots, then by snapshot you will find global ids, and just remove them in such order

global id -> snapshot -> commit properties -> commit

Upvotes: 1

Related Questions