3 Replies Latest reply on Feb 26, 2010 12:11 PM by adamw

    How to delete history down from a certain date?

    eiswind1

      Is it possible to delete AuditRecords with a date before xy ? I want to limit disk space consumpion and strore only the history of a certain period. How would the delete look like ? Can I do this with

       

      delete from entity_AUD where timestamp < :date

       

      Any hints would be appreciated !

        • 1. Re: How to delete history down from a certain date?
          adamw

          I think the best way is to:

          * make sure that the relations between audit tables and the revision info table (rev id <-> id) have delete cascade

          * delete from rev_info r where r.date < :date

           

          Adam

          • 2. Re: How to delete history down from a certain date?
            eiswind1

            Thanks Adam,

             

            how can I set the delete cascade on these tables ? AFAIK they are generated by envers and I have no influence on that, have I ?

             

            Regards Thomas

            • 3. Re: How to delete history down from a certain date?
              adamw

              Aren't they included in the auto-generated schema? If not, you can create a JIRA issue for that, though I'm not quite sure yet if this should be the default.

               

              I normally just generate the "initial" schema automatically and then include it in a sql-create script so that it can go in production. And there I can freely add constraints, cascades etc

               

              Also, if you add them manually, afaik they won't be removed by hbm2ddl.

               

              Adam