Master to 4.2.8
[usit-rt.git] / etc / upgrade / 4.1.5 / content
CommitLineData
af59614d
MKG
1use strict;
2use warnings;
3
4our @Initial = (
5 # upgrade Template from id to name
6 sub {
7 require RT::Scrips;
8 my $scrips = RT::Scrips->new( RT->SystemUser );
9 $scrips->UnLimit;
10 while ( my $scrip = $scrips->Next ) {
11 my $id = $scrip->Template;
12 if ( $id =~ /\D/ ) {
13 $RT::Logger->info('Template column for scrip #'. $scrip->id .' already contains characters');
14 next;
15 }
16
17 my $name;
18
19 my $template = RT::Template->new( RT->SystemUser );
20 $template->Load( $id );
21 unless ( $template->id ) {
22 $RT::Logger->error("Scrip #". $scrip->id ." has template set to #$id, but it's not in DB, setting it 'Blank'");
23 $name = 'Blank';
24 } else {
25 $name = $template->Name;
26 }
27
28 my ($status, $msg) = $scrip->_Set( Field => 'Template', Value => $name );
29 unless ( $status ) {
30 $RT::Logger->error("Couldn't set template: $msg");
31 }
32 }
33 },
34);