RT2-to-RT3 migration tool question

Hello all,

I have a RT 2 database which I am attempting to migrate up to RT3
using the RT2-to-RT3 migration tool found here: http://search.cpan.org/~falcone/RT-Extension-RT2toRT3-1.26/

Basically I am looking for a way to modify data on the fly while it is
being pulled out by this tool. Detailed walkthrough of what I am doing
follows below.

One of the code changes made to the database back in 2002 was a change
to the priority fields to reflect a word rather than a number.

So where RT2 normally has

InitialPriority init(11) default NULL

Our instance has

InitialPriority enum(‘urgent’,‘high’,‘medium’,‘low’,‘project’)
default NULL,

All *Priority columns in the tables Queues and Tickets are effected by
this change.

What I would like to do is using the RT2-to-RT3 migration tool take
the output that it is getting in preparation to dump to a file and on
the fly change the priority from word to numeric value. So where
priority = urgent, high, medium, low, or project the name is changed
to the value 90,70,50,20, and 10 respectively.

So after some debugging I found the area I need to target (at least
for the queues so far) at line #457 in the
rt2-to-dumpfile program specifically the program snippet below:

 foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
     my $queue_ds;
     foreach my $param ( sort @{$FIELD_MAPPINGS{'RT::Queue'}} ) {
         $queue_ds->{$param} = $Queue->_Value($param)
           if ( $Queue->_Value($param) );
     }

What I have done is put in the following:

 foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
     my $queue_ds;
     foreach my $param ( sort @{$FIELD_MAPPINGS{'RT::Queue'}} ) {
         if ($param eq "FinalPriority") {
             if ($Queue->__Value($param) eq 'urgent') {
                 $Queue->_Set($param) = '90';
             } elsif ($Queue->__Value($param) eq 'high') {
                 $Queue->_Set($param) = '70';
             } elsif ($Queue->__Value($param) eq 'medium') {
                 $Queue->_Set($param) = '50';
             } elsif ($Queue->__Value($param) eq 'low') {
                 $Queue->_Set($param) = '20';
             } elsif ($Queue->__Value($param) eq 'project') {
                 $Queue->_Set($param) = '10';
             } else { }
         }
         $queue_ds->{$param} = $Queue->_Value($param)
           if ( $Queue->_Value($param) );
     }

While this should work in theory based on reading the DBIx pages on
cpan it looks like there is no method by which to actually modify a
__Value only return that value. I know the program is correctly going
through the if value eq name tree as the first value it is being fed
is “low” and we error out with the following line.

Can’t modify non-lvalue subroutine call at ./rt-2.0-to-dumpfile line
551.

Is this a fruitless task or is it indeed possible to modify this value
in some method while going through the rt2-to-dumpfile program.

Or should I give up and rather create a script to copy the tables
Queues and Tickets pulling down their data and putting it back into a
new version that uses numeric values instead of name values.

Thanks for reading this far down, I am hoping someone has done
something similar…

  • Brian

Hello all,

I have a RT 2 database which I am attempting to migrate up to RT3
using the RT2-to-RT3 migration tool found here: RT-Extension-RT2toRT3-1.26 - This tool migrates your RT2 instance to an RT 3.x instance - metacpan.org

Basically I am looking for a way to modify data on the fly while it is
being pulled out by this tool. Detailed walkthrough of what I am doing
follows below.


One of the code changes made to the database back in 2002 was a change
to the priority fields to reflect a word rather than a number.

So where RT2 normally has

InitialPriority init(11) default NULL

Our instance has

InitialPriority enum(‘urgent’,‘high’,‘medium’,‘low’,‘project’)
default NULL,

All *Priority columns in the tables Queues and Tickets are effected by
this change.

What I would like to do is using the RT2-to-RT3 migration tool take
the output that it is getting in preparation to dump to a file and on
the fly change the priority from word to numeric value. So where
priority = urgent, high, medium, low, or project the name is changed
to the value 90,70,50,20, and 10 respectively.

So after some debugging I found the area I need to target (at least
for the queues so far) at line #457 in the
rt2-to-dumpfile program specifically the program snippet below:

foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
    my $queue_ds;
    foreach my $param ( sort @{$FIELD_MAPPINGS{'RT::Queue'}} ) {
        $queue_ds->{$param} = $Queue->_Value($param)
          if ( $Queue->_Value($param) );
    }

I think it’s pretty simple. Instead of the following:
if ($Queue->__Value($param) eq ‘urgent’) {
$Queue->_Set($param) = ‘90’;
where you try to change your RT2 DB, you can change temporary
$queue_ds hash the tool builds before pushing data into file,
something like that:

         if ($param eq "FinalPriority") {
             if ($Queue->__Value($param) eq 'urgent') {
                 $queue_ds->{$param} = '90';
             } elsif ($Queue->__Value($param) eq 'high') {
                 $queue_ds->{$param} = '70';
             } elsif ($Queue->__Value($param) eq 'medium') {
             ...
         }
         else {
            $queue_ds->{$param} = $Queue->_Value($param)
                   if ( $Queue->_Value($param) );
         }

What I have done is put in the following:

foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
    my $queue_ds;
    foreach my $param ( sort @{$FIELD_MAPPINGS{'RT::Queue'}} ) {
        if ($param eq "FinalPriority") {
            if ($Queue->__Value($param) eq 'urgent') {
                $Queue->_Set($param) = '90';
            } elsif ($Queue->__Value($param) eq 'high') {
                $Queue->_Set($param) = '70';
            } elsif ($Queue->__Value($param) eq 'medium') {
                $Queue->_Set($param) = '50';
            } elsif ($Queue->__Value($param) eq 'low') {
                $Queue->_Set($param) = '20';
            } elsif ($Queue->__Value($param) eq 'project') {
                $Queue->_Set($param) = '10';
            } else { }
        }
        $queue_ds->{$param} = $Queue->_Value($param)
          if ( $Queue->_Value($param) );
    }

While this should work in theory based on reading the DBIx pages on
cpan it looks like there is no method by which to actually modify a
__Value only return that value. I know the program is correctly going
through the if value eq name tree as the first value it is being fed
is “low” and we error out with the following line.

Can’t modify non-lvalue subroutine call at ./rt-2.0-to-dumpfile line
551.

Is this a fruitless task or is it indeed possible to modify this value
in some method while going through the rt2-to-dumpfile program.

Or should I give up and rather create a script to copy the tables
Queues and Tickets pulling down their data and putting it back into a
new version that uses numeric values instead of name values.

Thanks for reading this far down, I am hoping someone has done
something similar…

  • Brian

The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

Ah Ha!On Nov 6, 2008, at 4:03 PM, Ruslan Zakirov wrote:

On Fri, Nov 7, 2008 at 2:16 AM, Brian Friday brian.friday@gmail.com wrote:

What I would like to do is using the RT2-to-RT3 migration tool take
the output that it is getting in preparation to dump to a file and on
the fly change the priority from word to numeric value. So where
priority = urgent, high, medium, low, or project the name is changed
to the value 90,70,50,20, and 10 respectively.

So after some debugging I found the area I need to target (at least
for the queues so far) at line #457 in the
rt2-to-dumpfile program specifically the program snippet below:

foreach my $Queue ( @{ $Queues->ItemsArrayRef } ) {
my $queue_ds;
foreach my $param ( sort @{$FIELD_MAPPINGS{‘RT::Queue’}} ) {
$queue_ds->{$param} = $Queue->_Value($param)
if ( $Queue->_Value($param) );
}

I think it’s pretty simple. Instead of the following:
if ($Queue->__Value($param) eq ‘urgent’) {
$Queue->_Set($param) = ‘90’;
where you try to change your RT2 DB, you can change temporary
$queue_ds hash the tool builds before pushing data into file,
something like that:

        if ($param eq "FinalPriority") {
            if ($Queue->__Value($param) eq 'urgent') {
                $queue_ds-> {$param} = '90';
            } elsif ($Queue->__Value($param) eq 'high') {
                $queue_ds->{$param} = '70';
            } elsif ($Queue->__Value($param) eq 'medium') {
            ...
        }
        else {
           $queue_ds->{$param} = $Queue->_Value($param)
                  if ( $Queue->_Value($param) );
        }

Ah Ha! I knew I was missing something glaringly obvious but somehow I
didn’t see the nose or in this case the temporary hash in front of my
face.

For historical etc reference the code change I put in at 457 (which
works based on a data dumper output before and after) is the following:

         if (($param eq "FinalPriority") || ($param eq  

‘InitialPriority’)) {
if ($Queue->__Value($param) eq ‘urgent’) {
$queue_ds->{$param} = ‘90’;
} elsif ($Queue->__Value($param) eq ‘high’) {
$queue_ds->{$param} = ‘70’;
} elsif ($Queue->__Value($param) eq ‘medium’) {
$queue_ds->{$param} = ‘50’;
} elsif ($Queue->__Value($param) eq ‘low’) {
$queue_ds->{$param} = ‘20’;
} elsif ($Queue->__Value($param) eq ‘project’) {
$queue_ds->{$param} = ‘10’;
} elsif ($Queue->__Value($param) eq ‘back burner’) {
$queue_ds->{$param} = ‘5’;
}
} else {
$queue_ds->{$param} = $Queue->_Value($param)
if ( $Queue->_Value($param) );
}

Thanks for the quick assistance Ruslan!

  • Brian