You have few options depending on how lazy you are :D

a) lower the config:/server/version/maxVersionIndex value and reactivate whole 
site (when versioning the content on activation, all versions of content are 
checked and those exceeding the maxVersionIndex are removed).

b) lower the config:/server/version/maxVersionIndex and then run something like:
vMan = VersionManager.instance;
root = hm.root;
ContentUtil.visit(root, new ContentUtil.Visitor(){
   visit(Content node) {
     if(node.getIndex()>1){
       print(node);
       vMan.setMaxVersionHistory(node);
     }
   } 
});
from the groovy shell

c) be more sophisticated and do something like:
vMan = VersionManager.instance;
root = hm.root;
ContentUtil.visit(root, new ContentUtil.Visitor(){
   visit(Content node) {
     if(node.getIndex()>1){
       print(node);
       history = node.jCRNode.versionHistory;
       versions = history.allVersions;
       size = versions.size;
       // the root and base versions are the ones you always need
       if (size > 2) {
         // skip root
         versions.nextVersion();
         // we skipped the root and we want to skip base too
         size = size - 2;
         idx = 0;
         while (idx < size) {
           version = versions.nextVersion();
           // do something smart here, check if the date is older then X or 
something similar
           if (toBeDeleted) {
             history.removeVersion(version.name);
           }
         }
       }
     }
   } 
});

As you can see the a) option is not a really good one if you have a huge site 
as it will generate lots of load on both author and public, will force creation 
of yet another version and makes you activate everything ... I would not do 
that.

b) is more less the same thing without publishing and unnecessary versioning

c) is IMHO the best option. If you go that way please post your final script 
(or java task/command) on wiki.

BTW, all the above is written from top of my head (and/or copied from various 
wiki pages) so whatever you do, double or triple check the scripts and be sure 
to run them in some test environment first (I'm almost sure they will not run 
on first try anyway :D )

HTH,
Jan

On May 19, 2010, at 9:25 AM, Matteo Pelucco wrote:

> 
> Hi all,
> I notice that in our MySql DB the versioning tables grow a lot, we have 
> around 5 GB over 10 GB of overall data.
> 
> There is a way to "prune" the versions? For example, take only the last 
> version and remove the oldest?
> 
> Matteo
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------

-  
Best regards,

Jan Haderka, PhD.
Magnolia International Ltd.

http://www.magnolia-cms.com
http://twitter.com/magnolia_cms

You should join us on Facebook:
http://facebook.com/Magnolia

--------------------------------------

Magnolia®  - Simple Open-Source Content Management




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to