From 8251525fb6e353b7916a13e6c057631ad408990a Mon Sep 17 00:00:00 2001
From: sun <sun@unleashedmind.com>
Date: Fri, 2 Dec 2011 16:51:47 +0100
Subject: [PATCH 1/2] Fixed schema.

---
 block_class.install |   73 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/block_class.install b/block_class.install
index 491269d..563883d 100644
--- a/block_class.install
+++ b/block_class.install
@@ -5,32 +5,29 @@
  * Provides the (un)install and update logic for block_class.
  */
 
-
 /**
  * Implementation of hook_schema().
- *
- * @return array The schema information.
  */
 function block_class_schema() {
   $schema['block_class'] = array(
     'fields' => array(
       'module' => array(
         'type'        => 'varchar',
-        'length'      => '255',
+        'length'      => 64,
         'not null'    => TRUE,
-        'description' => t('The module to which the block belongs.'),
+        'description' => 'The module to which the block belongs.',
       ),
       'delta' => array(
         'type'        => 'varchar',
-        'length'      => '255', 
+        'length'      => 32,
         'not null'    => TRUE,
-        'description' => t("The ID of the module's block."),
+        'description' => "The ID of the module's block.",
       ),
       'css_class' => array(
         'type'        => 'varchar',
-        'length'      => '255',
+        'length'      => 255,
         'not null'    => TRUE,
-        'description' => t('String containing the classes for the block.'),
+        'description' => 'String containing the classes for the block.',
       ),
     ),
     'primary key' => array('module', 'delta'),
@@ -39,7 +36,6 @@ function block_class_schema() {
   return $schema;
 }
 
-
 /**
  * Implementation of hook_install().
  */
@@ -47,7 +43,6 @@ function block_class_install() {
   drupal_install_schema('block_class');
 }
 
-
 /**
  * Implementation of hook_uninstall().
  */
@@ -55,48 +50,70 @@ function block_class_uninstall() {
   drupal_uninstall_schema('block_class');
 }
 
-
 /**
- * Implementation of hook_update_N(). Alters the structure of the
- * block_class schema.
- *
- * @return array The results of the updates.
+ * Alters the structure of {block_class} schema.
  */
 function block_class_update_6100() {
-  $status = array();
+  $ret = array();
 
   // Update the schema.
-  db_drop_primary_key($status, 'block_class');
+  db_drop_primary_key($ret, 'block_class');
 
-  db_change_field($status, 'block_class', 'module', 'module',
+  db_change_field($ret, 'block_class', 'module', 'module',
     array(
       'type' => 'varchar',
       'length' => '255',
       'not null' => TRUE,
-      'description' => t('The module to which the block belongs.'),
+      'description' => 'The module to which the block belongs.',
     )
   );
-
-  db_change_field($status, 'block_class', 'delta', 'delta',
+  db_change_field($ret, 'block_class', 'delta', 'delta',
     array(
       'type' => 'varchar',
       'length' => '255',
       'not null' => TRUE,
-      'description' => t("The ID of the module's block."),
+      'description' => "The ID of the module's block.",
     )
   );
-
-  db_change_field($status, 'block_class', 'css_class', 'css_class',
+  db_change_field($ret, 'block_class', 'css_class', 'css_class',
     array(
       'type' => 'varchar',
       'size' => '255',
       'not null' => TRUE,
-      'description' => t('String containing the classes for the block.'),
+      'description' => 'String containing the classes for the block.',
     )
   );
 
   // Restore the primary key.
-  db_add_primary_key($status, 'block_class', array('module', 'delta'));
+  db_add_primary_key($ret, 'block_class', array('module', 'delta'));
+
+  return $ret;
+}
 
-  return $status;
+/**
+ * Fix too long primary key length in {block_class}.
+ */
+function block_class_update_6101() {
+  $ret = array();
+
+  // Drop current primary key.
+  db_drop_primary_key($ret, 'block_class');
+
+  db_change_field($ret, 'block_class', 'module', 'module', array(
+    'type' => 'varchar',
+    'length' => 64,
+    'not null' => TRUE,
+    'description' => 'The module to which the block belongs.',
+  ));
+  db_change_field($ret, 'block_class', 'delta', 'delta', array(
+    'type' => 'varchar',
+    'length' => 32,
+    'not null' => TRUE,
+    'description' => "The ID of the module's block.",
+  ));
+
+  // Create new primary key.
+  db_add_primary_key($ret, 'block_class', array('module', 'delta'));
+
+  return $ret;
 }
-- 
1.7.6.msysgit.0


From 8b450617f0a240a3b1199610d46f905e4272b182 Mon Sep 17 00:00:00 2001
From: sun <sun@unleashedmind.com>
Date: Mon, 12 Dec 2011 15:44:39 +0100
Subject: [PATCH 2/2] Removed update 6100 and merged into 6101.

---
 block_class.install |   59 +++++++++++++++-----------------------------------
 1 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/block_class.install b/block_class.install
index 563883d..01bb999 100644
--- a/block_class.install
+++ b/block_class.install
@@ -12,21 +12,21 @@ function block_class_schema() {
   $schema['block_class'] = array(
     'fields' => array(
       'module' => array(
-        'type'        => 'varchar',
-        'length'      => 64,
-        'not null'    => TRUE,
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
         'description' => 'The module to which the block belongs.',
       ),
       'delta' => array(
-        'type'        => 'varchar',
-        'length'      => 32,
-        'not null'    => TRUE,
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
         'description' => "The ID of the module's block.",
       ),
       'css_class' => array(
-        'type'        => 'varchar',
-        'length'      => 255,
-        'not null'    => TRUE,
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
         'description' => 'String containing the classes for the block.',
       ),
     ),
@@ -55,38 +55,9 @@ function block_class_uninstall() {
  */
 function block_class_update_6100() {
   $ret = array();
-
-  // Update the schema.
-  db_drop_primary_key($ret, 'block_class');
-
-  db_change_field($ret, 'block_class', 'module', 'module',
-    array(
-      'type' => 'varchar',
-      'length' => '255',
-      'not null' => TRUE,
-      'description' => 'The module to which the block belongs.',
-    )
-  );
-  db_change_field($ret, 'block_class', 'delta', 'delta',
-    array(
-      'type' => 'varchar',
-      'length' => '255',
-      'not null' => TRUE,
-      'description' => "The ID of the module's block.",
-    )
-  );
-  db_change_field($ret, 'block_class', 'css_class', 'css_class',
-    array(
-      'type' => 'varchar',
-      'size' => '255',
-      'not null' => TRUE,
-      'description' => 'String containing the classes for the block.',
-    )
-  );
-
-  // Restore the primary key.
-  db_add_primary_key($ret, 'block_class', array('module', 'delta'));
-
+  // Removed. This schema update made new installations fail due to a too long
+  // primary key index. Since many users updated to it already, the corrected
+  // schema change has been moved to block_class_update_6101() now.
   return $ret;
 }
 
@@ -111,6 +82,12 @@ function block_class_update_6101() {
     'not null' => TRUE,
     'description' => "The ID of the module's block.",
   ));
+  db_change_field($ret, 'block_class', 'css_class', 'css_class', array(
+    'type' => 'varchar',
+    'length' => 255,
+    'not null' => TRUE,
+    'description' => 'String containing the classes for the block.',
+  ));
 
   // Create new primary key.
   db_add_primary_key($ret, 'block_class', array('module', 'delta'));
-- 
1.7.6.msysgit.0

