[Rt-commit] rt branch, articles-upgrade, created. rt-3.9.7-919-ga2693b0

Kevin Falcone falcone at bestpractical.com
Thu Dec 23 12:27:09 EST 2010


The branch, articles-upgrade has been created
        at  a2693b0112098cbf1d6f53ef67e3c45bbc16f8a6 (commit)

- Log -----------------------------------------------------------------
commit 375fd64719ef8c0f4e9a72b94ba44c5aac7b745c
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Dec 17 17:10:10 2010 -0500

    fix pod so --help works

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index f8d30a9..01687c8 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -529,6 +529,7 @@ e.g. --datadir /path/to/
 =item dba
 
     dba's username
+
 =item dba-password
 
     dba's password

commit a5b5899b4e3ea580821f0a8916ead6033a7fc141
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Dec 22 22:32:55 2010 -0500

    Warn (using the error which will log to the screen) about RTFM tables

diff --git a/etc/upgrade/3.9.8/content b/etc/upgrade/3.9.8/content
new file mode 100644
index 0000000..6726a8e
--- /dev/null
+++ b/etc/upgrade/3.9.8/content
@@ -0,0 +1,22 @@
+ at Initial = sub {
+    my $dbh = $RT::Handle->dbh;
+    my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
+    my $found_fm_tables;
+    while ( my $table = $sth->fetchrow_hashref ) {
+        my $name = $table->{TABLE_NAME};
+        next unless $name =~ /^fm_/i;
+        $found_fm_tables->{lc $name}++;
+    }
+
+    unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} ) {
+        $RT::Logger->error("You appear to be upgrading from RTFM 2.0 - We don't support upgrading this old of an RTFM yet");
+    }
+
+    $RT::Logger->error("We found RTFM tables in your database.  Checking for content.");
+
+    my $result = $dbh->selectall_arrayref("SELECT count(*) AS articlecount FROM FM_Articles", { Slice => {} } );
+
+    if ($result->[0]{articlecount} > 0) {
+        $RT::Logger->error("You appear to have RTFM Articles.  You can upgrade using the etc/upgrade/upgrade-articles script.  Read more about it in UPGRADING");
+    }
+};

commit 9f3478d9fe8010a968c96ee66e83f0e1ec31c909
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 08:38:16 2010 -0500

    Initial upgrade-articles script
    
    This copies the existing 4 RTFM tables over to the new schema.
    It handles Classes without HotList columns
    
    It errors out if you're still running 2.0
    We'll need to handle FM_CustomFields and FM_Transactions
    for that.

diff --git a/.gitignore b/.gitignore
index ced6dc9..f554e13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ etc/upgrade/3.8-branded-queues-extension
 etc/upgrade/3.8-ical-extension
 etc/upgrade/split-out-cf-categories
 etc/upgrade/generate-rtaddressregexp
+etc/upgrade/upgrade-articles
 lib/RT/Generated.pm
 Makefile
 t/data/gnupg/keyrings/random_seed
diff --git a/configure.ac b/configure.ac
index 85fddd7..3d7de2c 100755
--- a/configure.ac
+++ b/configure.ac
@@ -387,6 +387,7 @@ AC_CONFIG_FILES([
                  etc/upgrade/3.8-ical-extension
                  etc/upgrade/split-out-cf-categories
                  etc/upgrade/generate-rtaddressregexp
+                 etc/upgrade/upgrade-articles
                  sbin/rt-attributes-viewer
                  sbin/rt-session-viewer
                  sbin/rt-dump-database
diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
new file mode 100644
index 0000000..8399072
--- /dev/null
+++ b/etc/upgrade/upgrade-articles.in
@@ -0,0 +1,121 @@
+#!@PERL@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
+#                                          <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+use strict;
+use warnings;
+
+use lib "@LOCAL_LIB_PATH@";
+use lib "@RT_LIB_PATH@";
+
+use RT;
+RT::LoadConfig();
+RT->Config->Set('LogToScreen' => 'debug');
+RT::Init();
+
+$| = 1;
+
+my $db_name = RT->Config->Get('DatabaseName');
+my $db_type = RT->Config->Get('DatabaseType');
+
+my $dbh = $RT::Handle->dbh;
+
+my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
+my $found_fm_tables;
+while ( my $table = $sth->fetchrow_hashref ) {
+    my $name = $table->{TABLE_NAME};
+    next unless $name =~ /^fm_/i;
+    $found_fm_tables->{lc $name}++;
+}
+
+unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} ) {
+    warn "Couldn't find topics tables, it appears you have RTFM 2.0 or earlier.";
+    warn "This script cannot yet upgrade RTFM versions which are that old";
+    exit;
+}
+
+{ # port over Articles
+    my @columns = qw(id Name Summary SortOrder Class Parent URI Creator Created LastUpdatedBy LastUpdated);
+    copy_tables('FM_Articles','Articles',\@columns);
+
+}
+
+
+{ # port over Classes
+    $sth = $dbh->column_info( undef, RT->Config->Get('DatabaseName'), 'FM_Classes','HotList');
+    my $result = $sth->fetchall_arrayref;
+    my @columns = qw(id Name Description SortOrder Disabled Creator Created LastUpdatedBy LastUpdated);
+    if (@$result) {
+        push @columns, 'HotList';
+    }
+    copy_tables('FM_Classes','Classes',\@columns);
+}
+
+{ # port over Topics
+    my @columns = qw(id Parent Name Description ObjectType ObjectId);
+    copy_tables('FM_Topics','Topics',\@columns);
+}
+
+{ # port over ObjectTopics
+    my @columns = qw(id Topic ObjectType ObjectId);
+    copy_tables('FM_ObjectTopics','ObjectTopics',\@columns);
+}
+
+sub copy_tables {
+    my ($source, $dest, $columns) = @_;
+    my $column_list = join(', ',@$columns);
+    if ( $db_type eq 'mysql' ) {
+        my $sql = "insert into $dest ($column_list) select $column_list from $source";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    } elsif ( $db_type eq 'Pg' ) {
+        my $sql = "insert into $dest ($column_list) (select $column_list from $source)";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    }
+    # oracle/sqlite, sigh
+}

commit e1f84c11b62028e64184c6ea2964c12ef8ed8a97
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 08:53:49 2010 -0500

    Apply every class globally
    
    In RTFM 2.4.3 and below, there was only the concept of a global class.

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 8399072..de9ed9f 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -105,6 +105,25 @@ unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} )
     copy_tables('FM_ObjectTopics','ObjectTopics',\@columns);
 }
 
+{ # create ObjectClasses
+  # this logic will need updating when folks have an FM_ObjectClasses table
+    use RT::Classes;
+    use RT::ObjectClasses;
+
+    my $classes = RT::Classes->new(RT->SystemUser);
+    $classes->UnLimit;
+    while ( my $class = $classes->Next ) {
+        my $objectclass = RT::ObjectClass->new(RT->SystemUser);
+        my ($ret, $msg ) = $objectclass->Create( Class => $class->Id, ObjectType => 'RT::System', ObjectId => 1 );
+        if ($ret) {
+            warn("Applied Class ".$class->Name." globally");
+        } else {
+            warn("Couldn't create linkage for Class ".$class->Name.": $msg");
+        }
+    }
+}
+
+
 sub copy_tables {
     my ($source, $dest, $columns) = @_;
     my $column_list = join(', ',@$columns);

commit 27b08989fd0c14d1aa30087a88487fa2668522d9
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 09:46:11 2010 -0500

    Fix ACLs to not refer to RT::FM
    
    ACEs *hate* being modified, and any attempt to use normal accessors
    causes them to try and load RT::FM::Class with hilarious warnings

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index de9ed9f..2563e51 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -116,13 +116,31 @@ unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} )
         my $objectclass = RT::ObjectClass->new(RT->SystemUser);
         my ($ret, $msg ) = $objectclass->Create( Class => $class->Id, ObjectType => 'RT::System', ObjectId => 1 );
         if ($ret) {
-            warn("Applied Class ".$class->Name." globally");
+            warn("Applied Class '".$class->Name."' globally");
         } else {
             warn("Couldn't create linkage for Class ".$class->Name.": $msg");
         }
     }
 }
 
+{ # update ACLs
+    use RT::ACL;
+    my $acl = RT::ACL->new(RT->SystemUser);
+    $acl->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Class' );
+    $acl->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::System' );
+    while ( my $ace = $acl->Next ) {
+        if ( $ace->__Value('ObjectType') eq 'RT::FM::Class' ) {
+            my ($ret, $msg ) = $ace->__Set( Field => 'ObjectType', Value => 'RT::Class');
+            warn "Fixing ACL ".$ace->Id." to refer to RT::Class: $msg";
+        } elsif ( $ace->__Value('ObjectType') eq 'RT::FM::System' ) {
+            my ($ret, $msg) = $ace->__Set(Field => 'ObjectType', Value => 'RT::System');
+            warn "Fixing ACL ".$ace->Id." to refer to RT::System: $msg";
+        }
+    }
+
+
+}
+
 
 sub copy_tables {
     my ($source, $dest, $columns) = @_;

commit faa35e65bc7497d2bdea76e927f6ae3d0d8936dc
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 09:57:57 2010 -0500

    Update LookupTypes on CustomFields

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 2563e51..1efd92f 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -105,6 +105,21 @@ unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} )
     copy_tables('FM_ObjectTopics','ObjectTopics',\@columns);
 }
 
+sub copy_tables {
+    my ($source, $dest, $columns) = @_;
+    my $column_list = join(', ',@$columns);
+    if ( $db_type eq 'mysql' ) {
+        my $sql = "insert into $dest ($column_list) select $column_list from $source";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    } elsif ( $db_type eq 'Pg' ) {
+        my $sql = "insert into $dest ($column_list) (select $column_list from $source)";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    }
+    # oracle/sqlite, sigh
+}
+
 { # create ObjectClasses
   # this logic will need updating when folks have an FM_ObjectClasses table
     use RT::Classes;
@@ -141,18 +156,13 @@ unless ( $found_fm_tables->{fm_topics} && $found_fm_tables->{fm_objecttopics} )
 
 }
 
-
-sub copy_tables {
-    my ($source, $dest, $columns) = @_;
-    my $column_list = join(', ',@$columns);
-    if ( $db_type eq 'mysql' ) {
-        my $sql = "insert into $dest ($column_list) select $column_list from $source";
-        $RT::Logger->debug($sql);
-        $dbh->do($sql);
-    } elsif ( $db_type eq 'Pg' ) {
-        my $sql = "insert into $dest ($column_list) (select $column_list from $source)";
-        $RT::Logger->debug($sql);
-        $dbh->do($sql);
+{ # update CustomFields
+    use RT::CustomFields;
+    my $cfs = RT::CustomFields->new(RT->SystemUser);
+    $cfs->Limit( FIELD => 'LookupType', VALUE => 'RT::FM::Class-RT::FM::Article' );
+    while ( my $cf = $cfs->Next ) {
+        my ($ret, $msg) = $cf->SetLookupType('RT::Class-RT::Article');
+        warn "Update Custom Field LookupType for CF.".$cf->Id." $msg";
     }
-    # oracle/sqlite, sigh
 }
+

commit f23e5027a92f86ec21c98e3cfe78cbba0e18e569
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 10:12:34 2010 -0500

    Fix Topics that refer to RT::FM
    
    Any attempt to access ObjectType triggers code that will explode
    on Topic->ObjectType->new unless we go through __Set and __Value

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 1efd92f..5dd33c0 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -166,3 +166,18 @@ sub copy_tables {
     }
 }
 
+{ # update Topics
+    use RT::Topics;
+    my $topics = RT::Topics->new(RT->SystemUser);
+    $topics->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Class' );
+    $topics->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::System' );
+    while ( my $topic = $topics->Next ) {
+        if ( $topic->__Value('ObjectType') eq 'RT::FM::Class' ) {
+            my ($ret, $msg ) = $topic->__Set( Field => 'ObjectType', Value => 'RT::Class');
+            warn "Fixing Topic ".$topic->Id." to refer to RT::Class: $msg";
+        } elsif ( $topic->__Value('ObjectType') eq 'RT::FM::System' ) {
+            my ($ret, $msg) = $topic->__Set(Field => 'ObjectType', Value => 'RT::System');
+            warn "Fixing Topic ".$topic->Id." to refer to RT::System: $msg";
+        }
+    }
+}

commit 5559bea49258d6e08006bf7f4ac0b08feca0502b
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 10:41:18 2010 -0500

    Point Topics to RT::Articles

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 5dd33c0..d12e3e7 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -181,3 +181,15 @@ sub copy_tables {
         }
     }
 }
+
+{ # update ObjectTopics
+    use RT::ObjectTopics;
+    my $otopics = RT::ObjectTopics->new(RT->SystemUser);
+    $otopics->UnLimit;
+    while ( my $otopic = $otopics->Next ) {
+        if ( $otopic->ObjectType eq 'RT::FM::Article' ) {
+            my ($ret, $msg) = $otopic->SetObjectType('RT::Article');
+            warn "Fixing Topic ".$otopic->Topic." to apply to article: $msg";
+        }
+    }
+}

commit 78b2af5e3c3bfa25c2b619157680c6b0d458c7d1
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 10:41:31 2010 -0500

    Point Custom Field values stored on articles to RT::Articles

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index d12e3e7..a3bb9ec 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -166,6 +166,17 @@ sub copy_tables {
     }
 }
 
+{ # update ObjectCustomFieldValues
+    use RT::ObjectCustomFieldValues;
+    my $ocfvs = RT::ObjectCustomFieldValues->new(RT->System);
+    $ocfvs->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Article' );
+    while ( my $ocfv = $ocfvs->Next ) {
+        my ($ret, $msg) = $ocfv->__Set( Field => 'ObjectType', Value => 'RT::Article' );
+        warn "Updated CF ".$ocfv->__Value('CustomField')." Value for Article ".$ocfv->__Value('ObjectId');
+    }
+
+}
+
 { # update Topics
     use RT::Topics;
     my $topics = RT::Topics->new(RT->SystemUser);

commit bc56f5bf5534db3a90b6c3e9bbb021d979500149
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 10:57:38 2010 -0500

    Put the parens in the proper place

diff --git a/lib/RT/Links_Overlay.pm b/lib/RT/Links_Overlay.pm
index bd5e915..04f4d7a 100755
--- a/lib/RT/Links_Overlay.pm
+++ b/lib/RT/Links_Overlay.pm
@@ -80,7 +80,7 @@ sub Limit  {
     #if someone's trying to search for tickets, try to resolve the uris for searching.
     
     if (  ( $args{'OPERATOR'} eq '=') and
-	  ( $args{'FIELD'}  eq 'Base') or ($args{'FIELD'} eq 'Target')
+	      ( ( $args{'FIELD'}  eq 'Base') or ($args{'FIELD'} eq 'Target') )
        ) {
 	  my $dummy = RT::URI->new($self->CurrentUser);
 	   $dummy->FromURI($args{'VALUE'});

commit 276138214cd3700560bf628a501338cc47439176
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 11:09:21 2010 -0500

    Update Links to fix fsck_com_rtfm -> fsck_com_article

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index a3bb9ec..a5233da 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -204,3 +204,23 @@ sub copy_tables {
         }
     }
 }
+
+{ # update Links
+    use RT::Links;
+    my $links = RT::Links->new(RT->SystemUser);
+    $links->Limit(FIELD => 'Base', VALUE => 'rtfm', OPERATOR => 'LIKE', SUBCLAUSE => 'stopanding', ENTRYAGGREGATOR => 'OR');
+    $links->Limit(FIELD => 'Target', VALUE => 'rtfm', OPERATOR => 'LIKE', SUBCLAUSE => 'stopanding', ENTRYAGGREGATOR => 'OR' );
+    while ( my $link = $links->Next ) {
+        my $base   = $link->__Value('Base');
+        my $target = $link->__Value('Target');
+        if ( $base =~ s/rtfm/article/i ) {
+            my ($ret, $msg) = $link->__Set( Field => 'Base', Value => $base );
+            warn "Updating base to $base: $msg for link ".$link->id;
+        }
+        if ( $target =~ s/rtfm/article/i ) {
+            my ($ret, $msg) = $link->__Set( Field => 'Target', Value => $target );
+            warn "Updating target to $target: $msg for link ".$link->id;
+        }
+
+    }
+}

commit 3cf134e8ed7177dfdf8648ff9fa6a5204243f114
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 11:31:11 2010 -0500

    Repoint RT::FM::Article transactions

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index a5233da..80f1b09 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -224,3 +224,15 @@ sub copy_tables {
 
     }
 }
+
+{ # update Transactions
+  # we only keep article transactions at this point
+    use RT::Transactions;
+    my $transactions = RT::Transactions->new(RT->SystemUser);
+    $transactions->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Article' );
+    while ( my $t = $transactions->Next ) {
+        my ($ret, $msg) = $t->__Set( Field => 'ObjectType', Value => 'RT::Article' );
+        warn "Updated Transaction ".$t->Id." to point to RT::Article";
+    }
+
+}

commit 3ad9ff384197ab2b40190e32f467cd907d0c2dae
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 11:32:25 2010 -0500

    Upgrade transactions that record links to articles

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 80f1b09..8c36e24 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -235,4 +235,14 @@ sub copy_tables {
         warn "Updated Transaction ".$t->Id." to point to RT::Article";
     }
 
+    # we also need to change links that point to articles
+    $transactions = RT::Transactions->new(RT->SystemUser);
+    $transactions->Limit( FIELD => 'Type', VALUE => 'AddLink' );
+    $transactions->Limit( FIELD => 'NewValue', VALUE => 'rtfm', OPERATOR => 'LIKE' );
+    while ( my $t = $transactions->Next ) {
+        my $value = $t->__Value('NewValue');
+        $value =~ s/rtfm/article/;
+        my ($ret, $msg) = $t->__Set( Field => 'NewValue', Value => $value );
+        warn "Updated Transaction ".$t->Id." to link to $value";
+    }
 }

commit ffce595ffb2bdfe603c71887e9bba2486cf84543
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 11:41:21 2010 -0500

    Update Attributes that control how Classes insert CFs into messages

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 8c36e24..f1c3415 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -246,3 +246,14 @@ sub copy_tables {
         warn "Updated Transaction ".$t->Id." to link to $value";
     }
 }
+
+{ # update Attributes
+  # these are all things we should make real columns someday
+    use RT::Attributes;
+    my $attributes = RT::Attributes->new(RT->SystemUser);
+    $attributes->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Class' );
+    while ( my $a = $attributes->Next ) {
+        my ($ret,$msg) = $a->__Set( Field => 'ObjectType', Value => 'RT::Class' );
+        warn "Updating Attribute ".$a->Name." to point to RT::Class";
+    }
+}

commit b94d8b727caf31c6b31c35652a4465086560e209
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 11:57:24 2010 -0500

    Calling SetLookupType will helpfully go delete your ObjectCustomFields

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index f1c3415..c739973 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -161,7 +161,7 @@ sub copy_tables {
     my $cfs = RT::CustomFields->new(RT->SystemUser);
     $cfs->Limit( FIELD => 'LookupType', VALUE => 'RT::FM::Class-RT::FM::Article' );
     while ( my $cf = $cfs->Next ) {
-        my ($ret, $msg) = $cf->SetLookupType('RT::Class-RT::Article');
+        my ($ret, $msg) = $cf->__Set( Field => 'LookupType', Value => 'RT::Class-RT::Article' );
         warn "Update Custom Field LookupType for CF.".$cf->Id." $msg";
     }
 }

commit 1c00409b77c049217820c6827864aa2a9ab9b06e
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 12:03:54 2010 -0500

    Global is actually id 0 not 1

diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index c739973..4c55802 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -123,13 +123,13 @@ sub copy_tables {
 { # create ObjectClasses
   # this logic will need updating when folks have an FM_ObjectClasses table
     use RT::Classes;
-    use RT::ObjectClasses;
+    use RT::ObjectClass;
 
     my $classes = RT::Classes->new(RT->SystemUser);
     $classes->UnLimit;
     while ( my $class = $classes->Next ) {
         my $objectclass = RT::ObjectClass->new(RT->SystemUser);
-        my ($ret, $msg ) = $objectclass->Create( Class => $class->Id, ObjectType => 'RT::System', ObjectId => 1 );
+        my ($ret, $msg ) = $objectclass->Create( Class => $class->Id, ObjectType => 'RT::System', ObjectId => 0 );
         if ($ret) {
             warn("Applied Class '".$class->Name."' globally");
         } else {

commit a2693b0112098cbf1d6f53ef67e3c45bbc16f8a6
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 23 12:13:01 2010 -0500

    Simplistic upgrade instructions for upgrade-articles

diff --git a/UPGRADING b/UPGRADING
index df5c70f..9de47f6 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -20,6 +20,33 @@ well.
 
 
 *******
+UPGRADING FROM RT 3.8.x and RTFM 2.1 or greater
+
+RT4 now includes an Articles functionality, merged from RTFM.
+You should not install and enable the RT::FM plugin separately on RT 4.
+If you have existing data in RTFM, you can use the etc/upgrade/upgrade-articles
+script to upgrade that data.
+
+When running normal upgrade scripts, RT will warn if it finds existing
+RTFM tables that contain data and point you to the upgrade-aricles script.
+
+This script should be run from your RT tarball.  It will immediately
+begin populating your new RT4 tables with data from RTFM.  If you have
+browsed in the RT4 UI and created new classes and articles, this script
+will fail spectacularly.  Do *not* run this except on a fresh upgrade of
+RT.
+
+You can run this as
+
+  etc/upgrade/upgrade-articles
+
+It will ouput a lot of data about what it is changing.  You should
+review this for errors.
+
+If you are running RTFM 2.0 with a release of RT, there isn't currently an upgrade
+script that can port RTFM's internal CustomField and Transaction data to RT4.
+
+*******
 UPGRADING FROM RT 3.8.x - Changes:
 
 The deprecated classes RT::Action::Generic, RT::Condition::Generic and RT::Search::Generic
diff --git a/UPGRADING.rtfm b/UPGRADING.rtfm
deleted file mode 100644
index 82c4f41..0000000
--- a/UPGRADING.rtfm
+++ /dev/null
@@ -1,97 +0,0 @@
-Upgrade instructions (From any 2.2.x release)
------------------------------------------------------
-
-There were no database changes from 2.2 to 2.4
-you should be able to follow the normal
-installation instructions which will overwrite
-existing RTFM code with the 2.4 version.
-
-Do not run the make initdb command
-
-It is recommended that you make a backup of your
-/opt/rt3 directory in case there are problems
-
-After installing 2.4, stop and start your web
-server, clearing your mason cache if necesary.
-
-If you installed an earlier version of RTFM on
-mysql 4.0 and are now upgrading to 4.1 or higher,
-you need to upgrade the database tables types.
-This is similar to the process for RT.
-See UPGRADING.mysql
-
-Upgrade Instructions from 2.1.x
------------------------------------------------------
-
-1) perl Makefile.PL
-
-2) make install
-
-3) Type "ls etc/upgrade"; For each item in that directory whose name
-   is greater than your previously installed RTFM version, run:
-
-            /opt/rt3/sbin/rt-setup-database --action schema \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action acl \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action insert \
-                 --datadir etc/upgrade/<version>
-
-   For the 2.2.0RC2 updates and 2.1.30 updates you may need to
-   run these as a superuser because they issue ALTER TABLE statements.
-
-   You can do this by adding the --dba root --prompt-for-dba-password
-   flags, like so:
-
-            /opt/rt3/sbin/rt-setup-database --action schema \
-                --dba root --prompt-for-dba-password \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action acl \
-                --dba root --prompt-for-dba-password \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action insert \
-                --dba root --prompt-for-dba-password \
-                 --datadir etc/upgrade/<version>
-
-4) If you are running 3.8, you need to enable RTFM in your 
-   RT_SiteConfig.pm file.  You can do this by adding the following
-   line:
-
-   Set(@Plugins,qw(RT::FM));
-
-5) clear your mason cache.  This is most often accomplished with
-   rm -rf /opt/rt3/var/mason_data/*
-
-6) stop and start your web server
-
-
-Upgrade instructions (From any  2.0.x release):
------------------------------------------------------
-
-1) perl Makefile.PL
-
-2) perl -I/path/to/your/rt/lib etc/upgrade/migrate-2.0-to-2.1
-
-if you are installing 2.4.x on a new machine and have brought
-your old 2.0.x database over, you will need a copy of the
-RTFM 2.0 libs.  You can bring these from your old machine or
-download them from http://download.bestpractical.com
-This command would then be
-
-perl -I/path/to/your/old/rtfm/lib -I/path/to/rt/lib etc/upgrade/migrate-2.0-to-2.1
-
-3) Type "make install"
-
-4) Type "ls etc/upgrade"; For each item in that directory whose name
-   is greater than your previously installed RTFM version, run:
-
-            /opt/rt3/sbin/rt-setup-database --action schema \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action acl \
-                --datadir etc/upgrade/<version>
-            /opt/rt3/sbin/rt-setup-database --action insert \
-                 --datadir etc/upgrade/<version>
-
-5) See note in ugprading from 2.2.x about UPGRADING.mysql
-
-6) stop and start your web server

-----------------------------------------------------------------------


More information about the Rt-commit mailing list