Dan Vrátil 660e89
commit 4ca8b846baaad48ebbd723f6411f9571a3b0f5ad
Dan Vrátil 660e89
Author: Dan Vrátil <dvratil@redhat.com>
Dan Vrátil 660e89
Date:   Tue Apr 22 11:28:07 2014 +0200
Dan Vrátil 660e89
Dan Vrátil 660e89
    Remove the invalid GID part from PartTable before starting PartTable migration
Dan Vrátil 660e89
    
Dan Vrátil 660e89
    More people than we expected have invalid 'GID' part in their PartTable,
Dan Vrátil 660e89
    which breaks migration to schema 25, because it expects all part types
Dan Vrátil 660e89
    to have a valid name.
Dan Vrátil 660e89
    
Dan Vrátil 660e89
    To work around this fact, we DELETE all parts with name 'GID' from PartTable
Dan Vrátil 660e89
    before starting the actual migration. This will not fix the migration for
Dan Vrátil 660e89
    people with other invalid parts, but I haven't heard of any such. To make
Dan Vrátil 660e89
    this completely bullet-proof, we would need to iterate through all entries,
Dan Vrátil 660e89
    which would be massively slower than current INSERT INTO ... SELECT FROM approach.
Dan Vrátil 660e89
    
Dan Vrátil 660e89
    Distributions, this is a good choice for backporting into 1.12.1 ;-)
Dan Vrátil 660e89
    
Dan Vrátil 660e89
    BUG: 331867
Dan Vrátil 660e89
    FIXED-IN: 1.12.2
Dan Vrátil 660e89
Dan Vrátil 660e89
diff --git a/server/src/storage/dbupdater.cpp b/server/src/storage/dbupdater.cpp
Dan Vrátil 660e89
index ccaf584..d6368b5 100644
Dan Vrátil 660e89
--- a/server/src/storage/dbupdater.cpp
Dan Vrátil 660e89
+++ b/server/src/storage/dbupdater.cpp
Dan Vrátil 660e89
@@ -261,6 +261,15 @@ bool DbUpdater::complexUpdate_25()
Dan Vrátil 660e89
     }
Dan Vrátil 660e89
   }
Dan Vrátil 660e89
 
Dan Vrátil 660e89
+  {
Dan Vrátil 660e89
+    // It appears that more users than expected have the invalid "GID" part in their
Dan Vrátil 660e89
+    // PartTable, which breaks the migration below (see BKO#331867), so we apply this
Dan Vrátil 660e89
+    // wanna-be fix to remove the invalid part before we start the actual migration.
Dan Vrátil 660e89
+    QueryBuilder qb( QLatin1String( "PartTable" ), QueryBuilder::Delete );
Dan Vrátil 660e89
+    qb.addValueCondition( QLatin1String( "PartTable.name" ), Query::Equals, QLatin1String( "GID" ) );
Dan Vrátil 660e89
+    qb.exec();
Dan Vrátil 660e89
+  }
Dan Vrátil 660e89
+
Dan Vrátil 660e89
   akDebug() << "Creating a PartTable_new";
Dan Vrátil 660e89
   {
Dan Vrátil 660e89
     TableDescription description;