[Rt-commit] rtir branch, rt-3.9, updated. 77e2cbdb456a5b3dd5ba5c2c4406a0c2a0976104

? sunnavy sunnavy at bestpractical.com
Mon Oct 18 07:39:56 EDT 2010


The branch, rt-3.9 has been updated
       via  77e2cbdb456a5b3dd5ba5c2c4406a0c2a0976104 (commit)
      from  453382ff7ad1d48999ab0cc121bcb78d01f1914c (commit)

Summary of changes:
 etc/upgrade/2.7.0/content |  106 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 etc/upgrade/2.7.0/content

- Log -----------------------------------------------------------------
commit 77e2cbdb456a5b3dd5ba5c2c4406a0c2a0976104
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Oct 18 19:37:16 2010 +0800

    upgrade script for 3.9

diff --git a/etc/upgrade/2.7.0/content b/etc/upgrade/2.7.0/content
new file mode 100644
index 0000000..8cd7041
--- /dev/null
+++ b/etc/upgrade/2.7.0/content
@@ -0,0 +1,106 @@
+
+ at Initial = (
+
+    # IP type change
+    sub {
+        my $ip_cf = RT::CustomField->new($RT::SystemUser);
+        $ip_cf->Load('IP');
+        if ( $ip_cf->id ) {
+            $ip_cf->SetType('IPAddressRange');
+            $ip_cf->SetMaxValue(0);
+            $ip_cf->SetPattern('');
+        }
+    },
+
+    #
+    # CF.State => Status
+    sub {
+        my %state;
+        for my $queue ( 'Incidents', 'Incident Reports', 'Investigations',
+            'Blocks' )
+        {
+            my $state = RT::CustomField->new($RT::SystemUser);
+            $state->LoadByName( Name => 'State', Queue => $queue );
+            $state{$queue} = $state if $state->id;
+        }
+
+        my $Tickets = RT::Tickets->new($RT::SystemUser);
+        $Tickets->UnLimit;
+        while ( my $ticket = $Tickets->Next ) {
+            next
+              unless $ticket->QueueObj->Name =~
+                  /^(Incidents|Incident Reports|Investigations|Blocks)$/;
+            my $txns = $ticket->Transactions;
+            my %done; # in case redo search bite
+            while ( my $txn = $txns->Next ) {
+                next if $done{$txn->id}++;
+                if ( $txn->Field eq 'Status' ) {
+                    $txn->Delete;
+                }
+                elsif ($txn->Type eq 'CustomField'
+                    && $txn->Field == $state{ $ticket->QueueObj->Name }->id )
+                {
+                    $txn->__Set( Field => 'Type', Value => 'Set' );
+                    $txn->__Set( Field => 'Field', Value => 'Status' );
+                    $txn->__Set( Field => 'ReferenceType', Value => '' );
+
+                    if ( $txn->OldReference ) {
+                        $ocfv =
+                          RT::ObjectCustomFieldValue->new($RT::SystemUser);
+                        $ocfv->Load( $txn->OldReference );
+                        $txn->__Set(
+                            Field => 'OldValue',
+                            Value => $ocfv->Content
+                        );
+                        $txn->__Set( Field => 'OldReference', Value => '' );
+                        $ocfv->Delete;
+                    }
+
+                    if ( $txn->NewReference ) {
+                        $ocfv =
+                          RT::ObjectCustomFieldValue->new($RT::SystemUser);
+                        $ocfv->Load( $txn->NewReference );
+                        $txn->__Set(
+                            Field => 'NewValue',
+                            Value => $ocfv->Content
+                        );
+                        $txn->__Set( Field => 'NewReference', Value => '' );
+                        $ocfv->Delete;
+                    }
+                }
+            }
+        }
+
+        for my $queue ( keys %state ) {
+            $state{$queue}->SetDisabled(1);
+        }
+    },
+
+    # remove state scrips: 2 actions and 2 scrips
+    sub {
+        for my $name (qw/Incident Investigation/) {
+            my $queue = RT::Queue->new($RT::SystemUser);
+            $queue->Load( $name . 's' );
+            next unless $queue->id;
+
+            my $action = RT::ScripAction->new($RT::SystemUser);
+            $action->Load("RTIR Set $name State");
+            next unless $action->id;
+
+            my $scrip = RT::Scrip->new($RT::SystemUser);
+            $scrip->LoadByCols(
+                Description => 'SetRTIRState',
+                Queue       => $queue->id,
+                ScripAction => $action->id,
+            );
+
+            if ( $scrip->id ) {
+                $scrip->Delete;
+            }
+
+            # hmm, RT::ScripAction currently doesn't allow Delete
+            # so the following code doesn't actually work.
+            $action->Delete();
+        }
+    },
+);

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


More information about the Rt-commit mailing list