summaryrefslogtreecommitdiff
path: root/rt/etc/upgrade/4.1.17/content
blob: 2e6a78cda0b43ac2ffe7882dcf69a4ae9b191ee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings;

our @Initial = (sub {
    my $searches = RT::Attributes->new(RT->SystemUser);
    $searches->Limit( FIELD => 'Name', VALUE => 'SavedSearch' );
    $searches->OrderBy( FIELD => 'id' );

    while (my $search = $searches->Next) {
        my $content = $search->Content;
        next unless ref $content eq 'HASH';
        next unless ($content->{SearchType} || '') eq 'Chart';

        # Switch from PrimaryGroupBy to GroupBy name
        # Switch from "CreatedMonthly" to "Created.Monthly"
        $content->{GroupBy} ||= [delete $content->{PrimaryGroupBy}];
        for (@{$content->{GroupBy}}) {
            next if !defined || /\./;
            s/(?<=[a-z])(?=[A-Z])/./;
        }

        my ($ok, $msg) = $search->SetContent($content);
        RT->Logger->error("Unable to upgrade saved chart #@{[$search->id]}: $msg")
            unless $ok;
    }
});