
ruz at bestpractical
May 9, 2008, 7:42 AM
Post #1 of 1
(25 views)
Permalink
|
|
r12186 - rt/branches/3.8-TESTING/etc/upgrade
|
|
Author: ruz Date: Fri May 9 10:42:55 2008 New Revision: 12186 Added: rt/branches/3.8-TESTING/etc/upgrade/shrink_cgm_table.pl Log: * add CGM table shrinker Added: rt/branches/3.8-TESTING/etc/upgrade/shrink_cgm_table.pl ============================================================================== --- (empty file) +++ rt/branches/3.8-TESTING/etc/upgrade/shrink_cgm_table.pl Fri May 9 10:42:55 2008 @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +use 5.8.3; +use strict; +use warnings; + +use RT; +RT::LoadConfig(); +RT->Config->Set('LogToScreen' => 'debug'); +RT::Init(); + +use RT::CachedGroupMembers; +my $cgms = RT::CachedGroupMembers->new( $RT::SystemUser ); +$cgms->Limit( + FIELD => 'MemberId', + OPERATOR => '=', + VALUE => 'main.GroupId', + QUOTEVALUE => 0, + ENTRYAGGREGATOR => 'AND', +); +$cgms->Limit( + FIELD => 'id', + OPERATOR => '=', + VALUE => 'main.Via', + QUOTEVALUE => 0, + ENTRYAGGREGATOR => 'AND', +); +$cgms->FindAllRows; + +while ( my $loop_cgm = $cgms->Next ) { + my $descendants = RT::CachedGroupMembers->new( $RT::SystemUser ); + $descendants->Limit( + FIELD => 'Via', + VALUE => $loop_cgm->id, + ENTRYAGGREGATOR => 'AND', + ); + $descendants->Limit( + FIELD => 'id', + OPERATOR => '!=', + VALUE => 'main.Via', + QUOTEVALUE => 0, + ENTRYAGGREGATOR => 'AND', + ); + $descendants->FindAllRows; + + while ( my $rec = $descendants->Next ) { + my ($status) = $rec->Delete; + unless ($status) { + print STDERR "Couldn't delete CGM #". $rec->id; + exit 1; + } + } +} _______________________________________________ Rt-commit mailing list Rt-commit[at]lists.bestpractical.com http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
|