1 my $move_attributes = sub {
2 my ($table, $type, $column) = @_;
3 my $query = "UPDATE $table SET $column = (SELECT Content FROM Attributes WHERE"
4 ." Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
6 my $res = $RT::Handle->SimpleQuery( $query, $column, $type );
8 $RT::Logger->error("Failed to move $column on $type from Attributes into $table table");
12 $query = 'DELETE FROM Attributes WHERE Name = ? AND ObjectType = ?';
13 $res = $RT::Handle->SimpleQuery( $query, $column, $type );
15 $RT::Logger->error("Failed to delete $column on $type from Attributes");
23 return $move_attributes->( 'Users', 'RT::User', 'AuthToken');
26 return $move_attributes->( 'CustomFields', 'RT::CustomField', 'RenderType');
29 my $cfs = RT::CustomFields->new($RT::SystemUser);
32 while ( my $cf = $cfs->Next ) {
33 # Explicitly remove 'ORDER BY id asc' to emulate the
34 # previous functionality, where Pg might return the the
35 # rows in arbitrary order
36 $cf->Attributes->OrderByCols();
38 my $attr = $cf->FirstAttribute('BasedOn');
40 $cf->SetBasedOn($attr->Content);
42 $query = 'DELETE FROM Attributes WHERE Name = ? AND ObjectType = ?';
43 $res = $RT::Handle->SimpleQuery( $query, 'BasedOn', 'RT::CustomField' );
45 $RT::Logger->error("Failed to delete BasedOn CustomFields from Attributes");
51 $move_attributes->( 'CustomFields', 'RT::CustomField', 'ValuesClass')
54 my $query = "UPDATE CustomFields SET ValuesClass = NULL WHERE ValuesClass = ?";
55 my $res = $RT::Handle->SimpleQuery( $query, 'RT::CustomFieldValues' );
57 $RT::Logger->error("Failed to replace default with NULLs");
63 my $attr = RT->System->FirstAttribute('BrandedSubjectTag');
64 return 1 unless $attr;
66 my $map = $attr->Content || {};
67 while ( my ($qid, $tag) = each %$map ) {
68 my $queue = RT::Queue->new( RT->SystemUser );
70 unless ( $queue->id ) {
71 $RT::Logger->warning("Couldn't load queue #$qid. Skipping...");
75 my ($status, $msg) = $queue->SetSubjectTag($tag);
77 $RT::Logger->error("Couldn't set subject tag for queue #$qid: $msg");