Upgrade 4.0.17 clean.
[usit-rt.git] / etc / upgrade / 4.0.9 / content
1 @Initial = (
2     sub {
3         $RT::Logger->debug(
4             'Going to update empty Queue Lifecycle column to "default"');
5
6         my $queues = RT::Queues->new( RT->SystemUser );
7         $queues->FindAllRows;
8         $queues->Limit(
9             FIELD    => 'Lifecycle',
10             OPERATOR => 'IS',
11             VALUE    => 'NULL',
12         );
13
14         $queues->Limit(
15             FIELD           => 'Lifecycle',
16             VALUE           => '',
17             ENTRYAGGREGATOR => 'OR',
18         );
19
20         $queues->Limit(
21             FIELD           => 'Lifecycle',
22             VALUE           => 0,
23             ENTRYAGGREGATOR => 'OR',
24         );
25
26         while ( my $q = $queues->Next ) {
27             $q->SetLifecycle('default');
28         }
29     },
30     sub {
31         use strict;
32         my $groups = RT::Groups->new(RT->SystemUser);
33         $groups->Limit( FIELD    => 'Domain',
34                         OPERATOR => '=',
35                         VALUE    => 'Personal'
36                       );
37         $groups->LimitToDeleted;
38         while ( my $group = $groups->Next ) {
39             my $members = $group->MembersObj();
40             while ( my $member = $members->Next ) {
41                 my ( $ok, $msg ) = $group->DeleteMember( $member->MemberId );
42                 if ( !$ok ) {
43                     $RT::Logger->warn(   "Unable to remove group member "
44                                        . $member->id . ": "
45                                        . $msg );
46                 }
47             }
48             $group->PrincipalObj->Delete;
49             $group->RT::Record::Delete();
50         }
51     },
52 );