[Rt-commit] rt branch, articles-upgrade, updated. rt-3.9.7-925-ge697e26

Kevin Falcone falcone at bestpractical.com
Tue Dec 28 15:18:18 EST 2010


The branch, articles-upgrade has been updated
       via  e697e268b084affe59c99f6e3f60d9de091bcd93 (commit)
       via  816d9e57cdd473d80b344a877d2a4195156624ff (commit)
       via  51132971e7ed3f9aac1051471e667d2c46b7859d (commit)
      from  77209c3fde59313d6b089ceeb860fdf411fba8bb (commit)

Summary of changes:
 etc/rtfm/upgrade/2.1.0/acl.Oracle        |    4 -
 etc/rtfm/upgrade/2.1.0/acl.Pg            |   24 ---
 etc/rtfm/upgrade/2.1.0/acl.mysql         |    4 -
 etc/rtfm/upgrade/2.1.0/content           |    2 -
 etc/rtfm/upgrade/2.1.0/schema.Oracle     |   22 ---
 etc/rtfm/upgrade/2.1.0/schema.Pg         |   20 --
 etc/rtfm/upgrade/2.1.0/schema.mysql      |   20 --
 etc/rtfm/upgrade/2.1.30/acl.Oracle       |    4 -
 etc/rtfm/upgrade/2.1.30/acl.Pg           |    4 -
 etc/rtfm/upgrade/2.1.30/acl.mysql        |    4 -
 etc/rtfm/upgrade/2.1.30/content          |    2 -
 etc/rtfm/upgrade/2.1.30/schema.Oracle    |    7 -
 etc/rtfm/upgrade/2.2.0RC2/acl.Oracle     |    4 -
 etc/rtfm/upgrade/2.2.0RC2/acl.Pg         |    4 -
 etc/rtfm/upgrade/2.2.0RC2/acl.mysql      |    4 -
 etc/rtfm/upgrade/2.2.0RC2/content        |    2 -
 etc/rtfm/upgrade/2.2.0RC2/schema.Oracle  |    1 -
 etc/rtfm/upgrade/2.2.0RC2/schema.Pg      |    4 -
 etc/rtfm/upgrade/2.2.0RC2/schema.mysql   |    1 -
 etc/rtfm/upgrade/migrate-2.0-to-2.1      |  292 ------------------------------
 etc/rtfm/upgrade/upgrade-mysql-schema.pl |  248 -------------------------
 etc/upgrade/upgrade-mysql-schema.pl      |   25 +++-
 22 files changed, 24 insertions(+), 678 deletions(-)
 delete mode 100644 etc/rtfm/upgrade/2.1.0/acl.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.1.0/acl.Pg
 delete mode 100644 etc/rtfm/upgrade/2.1.0/acl.mysql
 delete mode 100644 etc/rtfm/upgrade/2.1.0/content
 delete mode 100644 etc/rtfm/upgrade/2.1.0/schema.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.1.0/schema.Pg
 delete mode 100644 etc/rtfm/upgrade/2.1.0/schema.mysql
 delete mode 100644 etc/rtfm/upgrade/2.1.30/acl.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.1.30/acl.Pg
 delete mode 100644 etc/rtfm/upgrade/2.1.30/acl.mysql
 delete mode 100644 etc/rtfm/upgrade/2.1.30/content
 delete mode 100644 etc/rtfm/upgrade/2.1.30/schema.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.1.30/schema.Pg
 delete mode 100644 etc/rtfm/upgrade/2.1.30/schema.mysql
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/acl.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/acl.Pg
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/acl.mysql
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/content
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/schema.Oracle
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/schema.Pg
 delete mode 100644 etc/rtfm/upgrade/2.2.0RC2/schema.mysql
 delete mode 100644 etc/rtfm/upgrade/migrate-2.0-to-2.1
 delete mode 100755 etc/rtfm/upgrade/upgrade-mysql-schema.pl

- Log -----------------------------------------------------------------
commit 51132971e7ed3f9aac1051471e667d2c46b7859d
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Dec 28 14:27:20 2010 -0500

    add RTFM tables to the upgrade list for users coming from < 3.8

diff --git a/etc/upgrade/upgrade-mysql-schema.pl b/etc/upgrade/upgrade-mysql-schema.pl
index bc59c97..69532c7 100755
--- a/etc/upgrade/upgrade-mysql-schema.pl
+++ b/etc/upgrade/upgrade-mysql-schema.pl
@@ -58,6 +58,10 @@ my @tables = qw(
     Tickets
     Transactions
     Users
+    FM_Articles
+    FM_Classes
+    FM_ObjectTopics
+    FM_Topics
 );
 
 my %charset = (
@@ -93,6 +97,23 @@ my %charset = (
         Name  => 'utf8',
         Description  => 'utf8',
     },
+    FM_Articles => {
+        Name => 'utf8',
+        Summary => 'utf8',
+        URI => 'ascii',
+    },
+    FM_Classes => {
+        Name => 'utf8',
+        Description => 'utf8',
+    },
+    FM_ObjectTopics => {
+        ObjectType => 'ascii',
+    },
+    FM_Topics => {
+        Name => 'utf8',
+        Description => 'utf8',
+        ObjectType => 'ascii',
+    },
     Groups                   => {
         Name  => 'utf8',
         Description  => 'utf8',

commit 816d9e57cdd473d80b344a877d2a4195156624ff
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Dec 28 14:27:30 2010 -0500

    These are now part of the RT core upgrade
    
    upgrade-articles and upgrade-mysql-schema.pl contain the bulk of
    the logic.  We will need to port migrate-2.0-to-2.1 so that much older
    RTFMs can bring their Custom Fields and Transactions forward.

diff --git a/etc/rtfm/upgrade/2.1.0/acl.Oracle b/etc/rtfm/upgrade/2.1.0/acl.Oracle
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.1.0/acl.Oracle
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.1.0/acl.Pg b/etc/rtfm/upgrade/2.1.0/acl.Pg
deleted file mode 100644
index 005beb5..0000000
--- a/etc/rtfm/upgrade/2.1.0/acl.Pg
+++ /dev/null
@@ -1,24 +0,0 @@
-
-sub acl {
-    my $dbh = shift;
-
-    my @acls;
-
-    my @tables = qw (
-FM_Topics_id_seq
-FM_Topics
-FM_ObjectTopics_id_seq
-FM_ObjectTopics
-    );
-
-    foreach my $table (@tables) {
-        push @acls,
-          "GRANT SELECT, INSERT, UPDATE, DELETE ON $table to "
-          . $RT::DatabaseUser . ";";
-
-    }
-    return (@acls);
-}
-1;
-
-
diff --git a/etc/rtfm/upgrade/2.1.0/acl.mysql b/etc/rtfm/upgrade/2.1.0/acl.mysql
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.1.0/acl.mysql
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.1.0/content b/etc/rtfm/upgrade/2.1.0/content
deleted file mode 100644
index 3117daf..0000000
--- a/etc/rtfm/upgrade/2.1.0/content
+++ /dev/null
@@ -1,2 +0,0 @@
-# nothing to do
-1;
diff --git a/etc/rtfm/upgrade/2.1.0/schema.Oracle b/etc/rtfm/upgrade/2.1.0/schema.Oracle
deleted file mode 100644
index 912ab99..0000000
--- a/etc/rtfm/upgrade/2.1.0/schema.Oracle
+++ /dev/null
@@ -1,22 +0,0 @@
-CREATE SEQUENCE FM_Topics_seq;
-CREATE TABLE FM_Topics (
-id NUMBER(11,0)
-  CONSTRAINT FM_Topics_key PRIMARY KEY,
-Parent NUMBER(11,0) DEFAULT 0 NOT NULL,
-Name varchar2(255) DEFAULT '' NOT NULL,
-Description varchar2(255) DEFAULT '' NOT NULL,
-ObjectType varchar2(64) DEFAULT '' NOT NULL,
-ObjectId NUMBER(11,0) NOT NULL
-);
-
-
-CREATE SEQUENCE FM_ObjectTopics_seq;
-CREATE TABLE FM_ObjectTopics (
-id NUMBER(11,0)
-  CONSTRAINT FM_ObjectTopics_key PRIMARY KEY,
-Topic NUMBER(11,0) NOT NULL,
-ObjectType varchar2(64) DEFAULT '' NOT NULL,
-ObjectId NUMBER(11,0) NOT NULL
-);
-
-
diff --git a/etc/rtfm/upgrade/2.1.0/schema.Pg b/etc/rtfm/upgrade/2.1.0/schema.Pg
deleted file mode 100644
index 28a8502..0000000
--- a/etc/rtfm/upgrade/2.1.0/schema.Pg
+++ /dev/null
@@ -1,20 +0,0 @@
-CREATE TABLE FM_Topics (
-id SERIAL,
-Parent integer NOT NULL DEFAULT 0,
-Name varchar(255) NOT NULL DEFAULT '',
-Description varchar(255) NOT NULL DEFAULT '',
-ObjectType varchar(64) NOT NULL DEFAULT '',
-ObjectId integer NOT NULL,
-PRIMARY KEY (id)
-);
-
-
-CREATE TABLE FM_ObjectTopics (
-id SERIAL,
-Topic integer NOT NULL,
-ObjectType varchar(64) NOT NULL DEFAULT '',
-ObjectId integer NOT NULL,
-PRIMARY KEY (id)
-);
-
-
diff --git a/etc/rtfm/upgrade/2.1.0/schema.mysql b/etc/rtfm/upgrade/2.1.0/schema.mysql
deleted file mode 100644
index 57d23e3..0000000
--- a/etc/rtfm/upgrade/2.1.0/schema.mysql
+++ /dev/null
@@ -1,20 +0,0 @@
-CREATE TABLE FM_Topics (
-id INTEGER NOT NULL AUTO_INCREMENT,
-Parent integer NOT NULL DEFAULT 0,
-Name varchar(255) NOT NULL DEFAULT '',
-Description varchar(255) NOT NULL DEFAULT '',
-ObjectType varchar(64) NOT NULL DEFAULT '',
-ObjectId integer NOT NULL,
-PRIMARY KEY (id)
-) TYPE=InnoDB;
-
-
-CREATE TABLE FM_ObjectTopics (
-id INTEGER NOT NULL AUTO_INCREMENT,
-Topic integer NOT NULL,
-ObjectType varchar(64) NOT NULL DEFAULT '',
-ObjectId integer NOT NULL,
-PRIMARY KEY (id)
-) TYPE=InnoDB;
-
-
diff --git a/etc/rtfm/upgrade/2.1.30/acl.Oracle b/etc/rtfm/upgrade/2.1.30/acl.Oracle
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.1.30/acl.Oracle
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.1.30/acl.Pg b/etc/rtfm/upgrade/2.1.30/acl.Pg
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.1.30/acl.Pg
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.1.30/acl.mysql b/etc/rtfm/upgrade/2.1.30/acl.mysql
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.1.30/acl.mysql
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.1.30/content b/etc/rtfm/upgrade/2.1.30/content
deleted file mode 100644
index 3117daf..0000000
--- a/etc/rtfm/upgrade/2.1.30/content
+++ /dev/null
@@ -1,2 +0,0 @@
-# nothing to do
-1;
diff --git a/etc/rtfm/upgrade/2.1.30/schema.Oracle b/etc/rtfm/upgrade/2.1.30/schema.Oracle
deleted file mode 100644
index 05269cf..0000000
--- a/etc/rtfm/upgrade/2.1.30/schema.Oracle
+++ /dev/null
@@ -1,7 +0,0 @@
-ALTER TABLE FM_Classes MODIFY Name NULL;
-
-ALTER TABLE FM_Articles MODIFY Name NULL;
-ALTER TABLE FM_Articles MODIFY Summary NULL;
-
-ALTER TABLE FM_Topics MODIFY Name NULL;
-ALTER TABLE FM_Topics MODIFY Description NULL;
diff --git a/etc/rtfm/upgrade/2.1.30/schema.Pg b/etc/rtfm/upgrade/2.1.30/schema.Pg
deleted file mode 100644
index e69de29..0000000
diff --git a/etc/rtfm/upgrade/2.1.30/schema.mysql b/etc/rtfm/upgrade/2.1.30/schema.mysql
deleted file mode 100644
index e69de29..0000000
diff --git a/etc/rtfm/upgrade/2.2.0RC2/acl.Oracle b/etc/rtfm/upgrade/2.2.0RC2/acl.Oracle
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/acl.Oracle
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/acl.Pg b/etc/rtfm/upgrade/2.2.0RC2/acl.Pg
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/acl.Pg
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/acl.mysql b/etc/rtfm/upgrade/2.2.0RC2/acl.mysql
deleted file mode 100644
index 73c16ae..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/acl.mysql
+++ /dev/null
@@ -1,4 +0,0 @@
-sub acl {
-    return ();
-}
-1;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/content b/etc/rtfm/upgrade/2.2.0RC2/content
deleted file mode 100644
index 3117daf..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/content
+++ /dev/null
@@ -1,2 +0,0 @@
-# nothing to do
-1;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/schema.Oracle b/etc/rtfm/upgrade/2.2.0RC2/schema.Oracle
deleted file mode 100644
index faac3e2..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/schema.Oracle
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE FM_Classes ADD HotList NUMBER(11,0) DEFAULT 0 NOT NULL;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/schema.Pg b/etc/rtfm/upgrade/2.2.0RC2/schema.Pg
deleted file mode 100644
index 11743a3..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/schema.Pg
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE FM_Classes ADD COLUMN HotList smallint;
-UPDATE FM_Classes SET HotList = 0;
-ALTER TABLE FM_Classes ALTER COLUMN HotList SET DEFAULT 0;
-ALTER TABLE FM_Classes ALTER COLUMN HotList SET NOT NULL;
diff --git a/etc/rtfm/upgrade/2.2.0RC2/schema.mysql b/etc/rtfm/upgrade/2.2.0RC2/schema.mysql
deleted file mode 100644
index 8a4cdfd..0000000
--- a/etc/rtfm/upgrade/2.2.0RC2/schema.mysql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE FM_Classes ADD COLUMN HotList int(2) NOT NULL DEFAULT 0;
diff --git a/etc/rtfm/upgrade/migrate-2.0-to-2.1 b/etc/rtfm/upgrade/migrate-2.0-to-2.1
deleted file mode 100644
index c74f1f7..0000000
--- a/etc/rtfm/upgrade/migrate-2.0-to-2.1
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/usr/bin/env perl
-# BEGIN BPS TAGGED BLOCK {{{
-# 
-# COPYRIGHT:
-#  
-# This software is Copyright (c) 1996-2009 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/copyleft/gpl.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 RT;
-RT::LoadConfig;
-RT::Init;
-use RT::FM::CustomFieldCollection;
-use Data::Dumper;
-
-use strict;
-use warnings;
-
-my $cf_data;
-my @aces_to_delete;
-
-# find each rtfm custom field
-my $cfs = RT::FM::CustomFieldCollection->new($RT::SystemUser);
-$cfs->UnLimit();
-while ( my $cf = $cfs->Next ) {
-    print "Migrating custom field " . $cf->id . ": " . $cf->Name . "\n";
-
-    $cf_data->{ $cf->id } = {
-        id          => $cf->id,
-        Name        => $cf->Name,
-        Type        => $cf->Type,
-        Description => $cf->Description,
-        SortOrder   => $cf->SortOrder
-    };
-
-    # if it has values, find its values
-
-    my $values = $cf->ValuesObj;
-    my @values;
-    while ( my $value = $values->Next ) {
-        print "\t It has a value " . $value->Name . "\n";
-        push @values,
-          {
-            Name        => $value->Name,
-            Description => $value->Description,
-            SortOrder   => $value->SortOrder
-          };
-
-    }
-
-    $cf_data->{ $cf->id }->{values} = \@values;
-
-    # find its acls
-    my $acl = RT::ACL->new($RT::SystemUser);
-    $acl->Limit(
-        FIELD => 'ObjectType',
-        VALUE => 'RT::FM::CustomField',
-    );
-
-    $acl->Limit(
-        FIELD => 'ObjectId',
-        VALUE => $cf->id
-    );
-    my @acl;
-    print "  Migrating access control\n";
-    while ( my $ace = $acl->Next ) {
-        my $item = {
-            ObjectType    => $ace->ObjectType,
-            ObjectId      => $ace->ObjectId,
-            RightName     => $ace->RightName,
-            PrincipalType => $ace->PrincipalType,
-            PrincipalId   => $ace->PrincipalId,
-            DelegatedBy   => $ace->DelegatedBy,
-            DelegatedFrom => $ace->DelegatedFrom,
-            id            => $ace->id
-        };
-
-        push @acl, $item;
-    }
-    $cf_data->{ $cf->id }->{_acl} = \@acl;
-
-    #
-    # find out which classes its tied to
-
-    use RT::FM::ClassCustomFieldCollection;
-    my $cf_classes = RT::FM::ClassCustomFieldCollection->new($RT::SystemUser);
-    $cf_classes->Limit( FIELD => 'CustomField', VALUE => $cf->id);
-    my @classes;
-    print " It's tied to these classes:\n";
-    while ( my $cfclass = $cf_classes->Next ) {
-        print "\t", $cfclass->ClassObj->Name, "\n";
-        push @classes,
-          { Class => $cfclass->Class, SortOrder => $cfclass->SortOrder };
-
-    }
-
-    $cf_data->{ $cf->id }->{_classes} = \@classes;
-
-    # clone it into core RT
-	my $type =  $cf_data->{$cf->id}{'Type'};
-	$type = 'WikitextSingle' if $type eq 'WikiTextSingle';
-    my $core_cf = RT::CustomField->new($RT::SystemUser);
-    my ( $id, $val ) = $core_cf->Create(
-        Name        => $cf_data->{$cf->id}{'Name'},
-        Type        => $type,
-        Description => $cf_data->{$cf->id}{'Description'},
-        SortOrder   => $cf_data->{$cf->id}{'SortOrder'},
-        LookupType  => 'RT::FM::Class-RT::FM::Article'
-
-    );
-    unless ($core_cf->id) { print "ERROR creating ".$cf->id.": $val ". Dumper($cf_data->{$cf->id}); die;}
-    print " Migrated core custom field.\n";
-
-    # cache old id, new id
-    $cf_data->{$cf->id}->{'newid'} = $core_cf->id;
-
-
-    #
-    # add its values to core RT
-    print " Adding values\n";
-    foreach my $val (@{$cf_data->{ $cf->id }->{values}}) {
-        my ($valid,$valmsg) = $core_cf->AddValue (Name => $val->{'Name'},
-                            Description => $val->{'Description'},
-                            SortOrder => $val->{'SortOrder'}
-                        );
-
-        print "\t",$val->{'Name'},$valmsg , "\n";
-    }   
-    #
-    # add its tied classes to RT
-    print " adding classes\n";
-    foreach my $class (@{$cf_data->{ $cf->id }->{_classes}}) {
-        my   $object_cf = RT::ObjectCustomField->new($RT::SystemUser);
-        my ($ocfid, $ocfmsg) =  $object_cf->Create(CustomField => $cf->id, ObjectId => $class->{'Class'});
-        print "\tClass " . $class->{'Class'} ." ". $ocfmsg ."\n";
-     
-    } 
-        #
-    # add its acls to core RT
-    foreach my $ace (@{$cf_data->{ $cf->id }->{_acl}}) {
-
-
-        my $name = $ace->{'RightName'};
-        $name = 'SeeCustomField' if $name eq 'ShowCustomField';
-        $name = 'AdminCustomField' if $name eq 'ModifyACL';
-        $name = 'AdminCustomField' if $name eq 'ModifyValues';
-        
-            my $newace = RT::ACE->new($RT::SystemUser);
-            
-            my ($cfid, $cfmsg) = $newace->Create( Object => '',
-	    ObjectType    => 'RT::CustomField',
-            ObjectId      => $core_cf->id,
-            RightName     => $name,
-            PrincipalType => $ace->{'PrincipalType'},
-            PrincipalId   => $ace->{'PrincipalId'},
-            DelegatedBy   => $ace->{'DelegatedBy'},
-            DelegatedFrom => $ace->{'DelegatedFrom'},
-            );
-    
-            push (@aces_to_delete,  $ace->{'id'});
-            print " $cfmsg"; 
-        }
-}
-
-# Find all articles
-    use RT::FM::Articles;
-my $articles = RT::FM::Articles->new($RT::SystemUser);
-$articles->UnLimit();
-
-#
-#   For each article
-
-print "Importing articles";
-while ( my $article = $articles->Next ) {
-    print "\t Working with article " . $article->Id . "\n";
-
-    #       find its custom fields
-
-    use RT::FM::ArticleCFValueCollection;
-    my $cfvs = RT::FM::ArticleCFValueCollection->new($RT::SystemUser);
-    $cfvs->LimitToArticle( $article->id );
-
-    #       for each custom field
-    print "Importing article custom field values\n";
-    while ( my $value = $cfvs->Next ) {
-    #       Add the value to the new custom field (without a txn)
-        my $ocfv = RT::ObjectCustomFieldValue->new($RT::SystemUser);
-    my ($ocid,$ocmsg) =  $ocfv->Create( ObjectType => 'RT::FM::Article',
-                        ObjectId => $value->Article,
-
-            CustomField => $cf_data->{$value->CustomField}->{'newid'},
-            Content => $value->Content );
-
-
-        print " $ocmsg\n";
-    }
-
-    #
-
-}
-
-# record transactions
-#
-use RT::FM::TransactionCollection;
-my $txns = RT::FM::TransactionCollection->new($RT::SystemUser);
-$txns->UnLimit();
-
-while ( my $txn = $txns->Next ) {
-
-    my $type = $txn->Type;
-    my $field = $txn->Field;
-    my $old_value = $txn->OldContent;
-    my $new_value = $txn->NewContent;
-    my $art = $txn->Article;
-
-
-    if ($type eq 'Link' && $new_value) {
-        $type = 'AddLink';
-    }
-    if ($type eq 'Link' && $old_value) {
-        $type = 'DeleteLink';
-    }
-
-    if ($type eq 'Custom') {
-        $type = 'CustomField';
-        $field = $cf_data->{$field}->{'newid'} || '0';
-    }
-
-    print "\tImporting transaction " . $txn->id . "\n";
-    my $new_txn = RT::Transaction->new($txn->CreatorObj);
-    my ($transid,$transmsg) = $new_txn->Create(
-        ObjectType => 'RT::FM::Article',
-        ObjectId   => $txn->Article,
-        Type => $type,
-        OldValue => $old_value,
-        NewValue => $new_value,
-	ActivateScrips => 0
-      );
-
-        print " $transmsg\n";
-}
-
-#
-#
-#
-# Delete outdated aces;
-#
-print "\nDeleting access control entries from old fields";
-foreach my $ace (@aces_to_delete) {
-    my $ACE = RT::ACE->new($RT::SystemUser);
-    $ACE->Load($ace);
-    $ACE->Delete();
-}
diff --git a/etc/rtfm/upgrade/upgrade-mysql-schema.pl b/etc/rtfm/upgrade/upgrade-mysql-schema.pl
deleted file mode 100755
index b29baa1..0000000
--- a/etc/rtfm/upgrade/upgrade-mysql-schema.pl
+++ /dev/null
@@ -1,248 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use DBI;
-use DBD::mysql 4.002;
-
-unless (@ARGV) {
-    print STDERR "usage: $0 db_name[:server_name] db_user db_password\n";
-    exit 1;
-}
-
-# pretty correct support of charsets has been introduced in mysql 4.1
-# as RT doesn't use it may result in issues:
-# 1) data corruptions when default charset of mysql server has data restrictions like utf8
-# 2) wrong ordering (collations)
-
-# we have to define correct types for all columns. RT uses UTF-8, ascii and binary.
-# * ascii is subset of many mysql's charsets except may be one or two rare where some ascii
-#   characters replaced with local
-# * for many charsets mysql allows us to store any octets sequences even when those are
-#   invalid for this particula set, for example we can store UTF-8 data in latin1
-#   column and fetch it as UTF-8, however sorting will be wrong
-
-# here is tricky algorithm to change column to desired charset:
-# * text to binary convertion is pretty straight forward except that text types
-#   have length definitions in terms of characters and in some cases we must
-#   use longer binary types to satisfy space requirements
-# * binary to text is much easier as we know that there is ascii or UTF-8 then
-#   we just make convertion, also 32 chars are long enough to store 32 bytes, so
-#   length changes is not required
-# * text to text convertion is trickier. no matter what is the current character set
-#   of the column we know that there is either ascii or UTF-8, so we can not use
-#   direct convertion, instead we do text to binary plus binary to text convertion
-#   instead
-# * as well we add charset definition for all tables and for the DB as well,
-#   so all new columns by default will be in UTF-8 charset
-
-my @tables = qw(
-    FM_Articles
-    FM_Classes
-    FM_ObjectTopics
-    FM_Topics
-);
-
-my %charset = (
-    FM_Articles => {
-        Name => 'utf8',
-        Summary => 'utf8',
-        URI => 'ascii',
-    },
-    FM_Classes => {
-        Name => 'utf8',
-        Description => 'utf8',
-    },
-    FM_ObjectTopics => {
-        ObjectType => 'ascii',
-    },
-    FM_Topics => {
-        Name => 'utf8',
-        Description => 'utf8',
-        ObjectType => 'ascii',
-    },
-);
-
-my %max_type_length = (
-    char       => int 1<<8,
-    varchar    => int 1<<8,
-    tinytext   => int 1<<8,
-    mediumtext => int 1<<16,
-    text       => int 1<<24,
-    longtext   => int 1<<32,
-);
-
-my @sql_commands;
-
-my ($db_datasource, $db_user, $db_pass) = (shift, shift, shift);
-my $dbh = DBI->connect("dbi:mysql:$db_datasource", $db_user, $db_pass, { RaiseError => 1 });
-my $db_name = $db_datasource;
-$db_name =~ s/:.*$//;
-
-my $version = ($dbh->selectrow_array("show variables like 'version'"))[1];
-($version) = $version =~ /^(\d+\.\d+)/;
-
-# do this from the RT level
-#push @sql_commands, qq{ALTER DATABASE $db_name DEFAULT CHARACTER SET utf8};
-convert_table($_) foreach @tables;
-
-print join "\n", map(/;$/? $_ : "$_;", @sql_commands), "";
-exit 0;
-
-my %alter_aggregator;
-sub convert_table {
-    my $table = shift;
-    @alter_aggregator{'char_to_binary','binary_to_char'} = (['DEFAULT CHARACTER SET utf8'],[]);
-
-    my $sth = $dbh->column_info( undef, $db_name, $table, undef );
-    $sth->execute;
-    while ( my $info = $sth->fetchrow_hashref ) {
-        convert_column(%$info);
-    }
-    for my $conversiontype (qw(char_to_binary binary_to_char)) {
-        next unless @{$alter_aggregator{$conversiontype}};
-        push @sql_commands, qq{ALTER TABLE $table\n   }.
-            join(",\n   ",@{$alter_aggregator{$conversiontype}});
-    }
-}
-
-sub convert_column {
-    my %info = @_;
-    my $table = $info{'TABLE_NAME'};
-    my $column = $info{'COLUMN_NAME'};
-    my $type = $info{'TYPE_NAME'};
-    return unless $type =~ /(CHAR|TEXT|BLOB|BINARY)$/i;
-
-    my $required_charset = $charset{$table}{$column};
-    unless ( $required_charset ) {
-        print STDERR join(".", @info{'TABLE_SCHEMA', 'TABLE_NAME', 'COLUMN_NAME'})
-            ." has type $type however mapping is missing.\n";
-        return;
-    }
-
-    my $collation = column_info($table, $column)->{'collation'};
-    # mysql 4.1 returns literal NULL instead of undef
-    my $current_charset = $collation && $collation ne 'NULL'? (split /_/, $collation)[0]: 'binary';
-    return if $required_charset eq $current_charset;
-
-    if ( $required_charset eq 'binary' ) {
-        char_to_binary(%info);
-    }
-    elsif ( $current_charset eq 'binary' ) {
-        binary_to_char( $required_charset, %info);
-    } else {
-        char_to_char( $required_charset, %info);
-    }
-}
-
-sub char_to_binary {
-    my %info = @_;
-
-    my $table = $info{'TABLE_NAME'};
-    my $column = $info{'COLUMN_NAME'};
-    my $new_type = calc_suitable_binary_type(%info);
-    push @{$alter_aggregator{char_to_binary}},
-        "MODIFY $column $new_type ".build_column_definition(%info);
-
-}
-
-sub binary_to_char {
-    my ($charset, %info) = @_;
-
-    my $table = $info{'TABLE_NAME'};
-    my $column = $info{'COLUMN_NAME'};
-    my $new_type = lc $info{'TYPE_NAME'};
-    if ( $new_type =~ /binary/ ) {
-        $new_type =~ s/binary/char/;
-        $new_type .= '('. $info{'COLUMN_SIZE'} .')';
-    } else {
-        $new_type =~ s/blob/text/;
-    }
-
-    push @{$alter_aggregator{binary_to_char}},
-        "MODIFY $column ". uc($new_type) ." CHARACTER SET ". $charset
-        ." ". build_column_definition(%info);
-}
-
-sub char_to_char {
-    my ($charset, %info) = @_;
-
-    my $table = $info{'TABLE_NAME'};
-    my $column = $info{'COLUMN_NAME'};
-    my $new_type = $info{'mysql_type_name'};
-
-    char_to_binary(%info);
-    push @{$alter_aggregator{binary_to_char}},
-        "MODIFY $column ". uc($new_type)." CHARACTER SET ". $charset
-        ." ". build_column_definition(%info);
-}
-
-sub calc_suitable_binary_type {
-    my %info = @_;
-    my $type = lc $info{'TYPE_NAME'};
-    return 'LONGBLOB' if $type eq 'longtext';
-
-    my $current_max_byte_length = column_byte_length(@info{qw(TABLE_NAME COLUMN_NAME)}) || 0;
-    if ( $max_type_length{ $type } > $current_max_byte_length ) {
-        if ( $type eq 'varchar' || $type eq 'char' ) {
-            my $new_type = $type;
-            $new_type =~ s/char/binary/;
-            $new_type .= $info{'COLUMN_SIZE'} >= $current_max_byte_length
-                ? '('. $info{'COLUMN_SIZE'} .')'
-                : '('. $current_max_byte_length .')';
-            return uc $new_type;
-        } else {
-            my $new_type = $type;
-            $new_type =~ s/text/blob/;
-            return uc $new_type;
-        }
-    } else {
-        my $new_type;
-        foreach ( sort { $max_type_length{$a} <=> $max_type_length{$b} } keys %max_type_length ) {
-            next if $max_type_length{ $_ } <= $current_max_byte_length;
-            
-            $new_type = $_; last;
-        }
-        $new_type =~ s/text/blob/;
-        return uc $new_type;
-    }
-}
-
-sub build_column_definition {
-    my %info = @_;
-
-    my $res = '';
-    $res .= 'NOT ' unless $info{'NULLABLE'};
-    $res .= 'NULL';
-    my $default = column_info(@info{qw(TABLE_NAME COLUMN_NAME)})->{default};
-    if ( defined $default ) {
-        $res .= ' DEFAULT '. $dbh->quote($default);
-    } elsif ( $info{'NULLABLE'} ) {
-        $res .= ' DEFAULT NULL';
-    }
-    $res .= ' AUTO_INCREMENT' if $info{'mysql_is_auto_increment'};
-    return $res;
-}
-
-sub column_byte_length {
-    my ($table, $column) = @_;
-    if ( $version >= 5.0 ) {
-        my ($char, $octet) = @{ $dbh->selectrow_arrayref(
-            "SELECT CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH FROM information_schema.COLUMNS WHERE"
-            ."     TABLE_SCHEMA = ". $dbh->quote($db_name)
-            ." AND TABLE_NAME   = ". $dbh->quote($table)
-            ." AND COLUMN_NAME  = ". $dbh->quote($column)
-        ) };
-        return $octet if $octet == $char;
-    }
-    return $dbh->selectrow_arrayref("SELECT MAX(LENGTH(". $dbh->quote_identifier($column) .")) FROM $table")->[0];
-}
-
-sub column_info {
-    my ($table, $column) = @_;
-    # XXX: DBD::mysql doesn't provide this info, may be will do in 4.0007 if I'll write a patch
-    local $dbh->{FetchHashKeyName} = 'NAME_lc';
-    return $dbh->selectrow_hashref("SHOW FULL COLUMNS FROM $table LIKE " . $dbh->quote($column));
-}
-

commit e697e268b084affe59c99f6e3f60d9de091bcd93
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Dec 28 15:17:44 2010 -0500

    Skip tables that don't exist
    
    Otherwise, we generated:
    ALTER TABLE nothere DEFAULT CHARSET utf8;
    which would just error out.

diff --git a/etc/upgrade/upgrade-mysql-schema.pl b/etc/upgrade/upgrade-mysql-schema.pl
index 69532c7..78288d2 100755
--- a/etc/upgrade/upgrade-mysql-schema.pl
+++ b/etc/upgrade/upgrade-mysql-schema.pl
@@ -260,7 +260,9 @@ sub convert_table {
 
     my $sth = $dbh->column_info( undef, $db_name, $table, undef );
     $sth->execute;
-    while ( my $info = $sth->fetchrow_hashref ) {
+    my $columns = $sth->fetchall_arrayref({});
+    return unless @$columns;
+    foreach my $info (@$columns) {
         convert_column(%$info);
     }
     for my $conversiontype (qw(char_to_binary binary_to_char)) {

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


More information about the Rt-commit mailing list