[Rt-commit] rt branch, 4.0/upgrading-basedon, updated. rt-4.0.0-237-g9d09522

Kevin Falcone falcone at bestpractical.com
Tue May 10 17:43:59 EDT 2011


The branch, 4.0/upgrading-basedon has been updated
       via  9d09522d2c256a5e6ce627670495d5165ae8a87b (commit)
      from  69da6caaac112c10b891f3b8a82050a20e146980 (commit)

Summary of changes:
 etc/upgrade/3.9.7/content |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 9d09522d2c256a5e6ce627670495d5165ae8a87b
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue May 10 17:40:42 2011 -0400

    Move BasedOn from Attributes to CustomFields.BasedOn
    
    Because 3.8 has always had a bug where you can get many many BasedOn
    Attributes, you need to LIMIT 1.  Instead, write perl code that will
    work across databases.  No need to write database specific sql.
    This will perform badly if you have many many CustomFields, but it
    handles the set of bugs known to me at this time.

diff --git a/etc/upgrade/3.9.7/content b/etc/upgrade/3.9.7/content
index 9dfb114..337932a 100644
--- a/etc/upgrade/3.9.7/content
+++ b/etc/upgrade/3.9.7/content
@@ -23,10 +23,24 @@ my $move_attributes = sub {
         return $move_attributes->( 'Users', 'RT::User', 'AuthToken');
     },
     sub {
-        return $move_attributes->( 'CustomFields', 'RT::CustomField', 'BasedOn');
+        return $move_attributes->( 'CustomFields', 'RT::CustomField', 'RenderType');
     },
     sub {
-        return $move_attributes->( 'CustomFields', 'RT::CustomField', 'RenderType');
+        my $cfs = RT::CustomFields->new($RT::SystemUser);
+        $cfs->UnLimit;
+        $cfs->FindAllRows;
+        while ( my $cf = $cfs->Next ) {
+            my $attr = $cf->FirstAttribute('BasedOn');
+            next unless $attr;
+            $cf->SetBasedOn($attr->Content);
+        }
+        $query = 'DELETE FROM Attributes WHERE Name = ? AND ObjectType = ?';
+        $res = $RT::Handle->SimpleQuery( $query, 'BasedOn', 'RT::CustomField' );
+        unless ( $res ) {
+            $RT::Logger->error("Failed to delete BasedOn CustomFields from Attributes");
+            return;
+        }
+        return 1;
     },
     sub {
         $move_attributes->( 'CustomFields', 'RT::CustomField', 'ValuesClass')

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


More information about the Rt-commit mailing list