[rt-users] RT2-to-RT3 migration tool question

Ruslan Zakirov ruz at bestpractical.com
Thu Nov 6 19:03:40 EST 2008


On Fri, Nov 7, 2008 at 2:16 AM, Brian Friday <brian.friday at gmail.com> wrote:
> 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) );
>         }

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
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at 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.



More information about the rt-users mailing list