4 my $move_attributes = sub {
5 my ($table, $type, $column) = @_;
6 my $query = "UPDATE $table SET $column = (SELECT Content FROM Attributes WHERE"
7 ." Name = ? AND ObjectType = ? AND $table.id = Attributes.ObjectId)";
9 my $res = RT->DatabaseHandle->SimpleQuery( $query, $column, $type );
11 RT->Logger->error("Failed to move $column on $type from Attributes into $table table");
15 $query = 'DELETE FROM Attributes WHERE Name = ? AND ObjectType = ?';
16 $res = RT->DatabaseHandle->SimpleQuery( $query, $column, $type );
18 RT->Logger->error("Failed to delete $column on $type from Attributes");
26 return $move_attributes->( 'Users', 'RT::User', 'AuthToken');
29 return $move_attributes->( 'CustomFields', 'RT::CustomField', 'RenderType');
32 my $cfs = RT::CustomFields->new( RT->SystemUser );
35 while ( my $cf = $cfs->Next ) {
36 # Explicitly remove 'ORDER BY id asc' to emulate the
37 # previous functionality, where Pg might return the the
38 # rows in arbitrary order
39 $cf->Attributes->OrderByCols();
41 my $attr = $cf->FirstAttribute('BasedOn');
43 $cf->SetBasedOn($attr->Content);
45 my $query = 'DELETE FROM Attributes WHERE Name = ? AND ObjectType = ?';
46 my $res = RT->DatabaseHandle->SimpleQuery( $query, 'BasedOn', 'RT::CustomField' );
48 RT->Logger->error("Failed to delete BasedOn CustomFields from Attributes");
54 $move_attributes->( 'CustomFields', 'RT::CustomField', 'ValuesClass')
57 my $query = "UPDATE CustomFields SET ValuesClass = NULL WHERE ValuesClass = ?";
58 my $res = RT->DatabaseHandle->SimpleQuery( $query, 'RT::CustomFieldValues' );
60 RT->Logger->error("Failed to replace default with NULLs");
66 my $attr = RT->System->FirstAttribute('BrandedSubjectTag');
67 return 1 unless $attr;
69 my $map = $attr->Content || {};
70 while ( my ($qid, $tag) = each %$map ) {
71 my $queue = RT::Queue->new( RT->SystemUser );
73 unless ( $queue->id ) {
74 RT->Logger->warning("Couldn't load queue #$qid. Skipping...");
78 my ($status, $msg) = $queue->SetSubjectTag($tag);
80 RT->Logger->error("Couldn't set subject tag for queue #$qid: $msg");