diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index c159049..d1a9395 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -206,8 +206,8 @@ function comment_schema() { 'comment_status_pid' => array('pid', 'status'), 'comment_num_new' => array( 'entity_id', - 'entity_type', - 'field_name', + array('entity_type', 32), + array('field_name', 32), 'status', 'created', 'cid', @@ -216,8 +216,8 @@ function comment_schema() { 'comment_uid' => array('uid'), 'comment_entity_langcode' => array( 'entity_id', - 'entity_type', - 'field_name', + array('entity_type', 32), + array('field_name', 32), 'langcode', ), 'comment_created' => array('created'), @@ -291,7 +291,7 @@ function comment_schema() { 'description' => 'The total number of comments on this entity.', ), ), - 'primary key' => array('entity_id', 'entity_type', 'field_name'), + 'primary key' => array('entity_id', array('entity_type', 32), array('field_name', 32)), 'indexes' => array( 'last_comment_timestamp' => array('last_comment_timestamp'), 'comment_count' => array('comment_count'), @@ -449,14 +449,14 @@ function comment_update_8004() { * Updates the comment_node_statistics and comment tables to new structure. */ function comment_update_8005(&$sandbox) { - // Remove the comment_node foreign key. + // Drop the comment_node foreign key. if (db_index_exists('comment', 'comment_node')) { db_drop_index('comment', 'comment_node'); } - // Remove the comment_nid_langcode index. + // Drop old indexes. db_drop_index('comment', 'comment_nid_langcode'); - // Remove comment_num_new index to create new latter here. db_drop_index('comment', 'comment_num_new'); + // Add the entity_type and field_name columns to comment. db_add_field('comment', 'entity_type', array( 'type' => 'varchar', @@ -481,8 +481,8 @@ function comment_update_8005(&$sandbox) { )); db_add_index('comment', 'comment_num_new', array( 'entity_id', - 'entity_type', - 'field_name', + array('entity_type', 32), + array('field_name', 32), 'status', 'created', 'cid', @@ -491,22 +491,22 @@ function comment_update_8005(&$sandbox) { // Add the comment_entity_langcode index. db_add_index('comment', 'comment_entity_langcode', array( 'entity_id', - 'entity_type', - 'field_name', + array('entity_type', 32), + array('field_name', 32), 'langcode', )); - // Rename node_comment_statistics to comment_entity_statistics. - // Remove the statistics_node foreign key. + // We need to drop all indexes to make sure their constrains named properly. if (db_index_exists('node_comment_statistics', 'statistics_node')) { + // Remove the statistics_node foreign key. db_drop_index('node_comment_statistics', 'statistics_node'); } - // We need to drop all indexes to make sure their constrains named properly. db_drop_primary_key('node_comment_statistics'); db_drop_index('node_comment_statistics', 'node_comment_timestamp'); + // Rename {node_comment_statistics} to {comment_entity_statistics}. db_rename_table('node_comment_statistics', 'comment_entity_statistics'); - // Remove the statistics_node foreign key from entity_comment_statistics. + // Add the entity_type and field_name columns to comment_entity_statistics. db_add_field('comment_entity_statistics', 'entity_type', array( 'type' => 'varchar', @@ -529,9 +529,13 @@ function comment_update_8005(&$sandbox) { 'default' => 0, 'description' => 'The entity_id to which this comment is a reply.', )); + // Add indexes. + db_add_primary_key('comment_entity_statistics', array('entity_id', array('entity_type', 32), array('field_name',32))); db_add_index('comment_entity_statistics', 'last_comment_timestamp', array('last_comment_timestamp')); - db_add_primary_key('comment_entity_statistics', array('entity_id', 'entity_type', 'field_name')); + db_add_index('comment_entity_statistics', 'comment_count', array('comment_count')); + db_add_index('comment_entity_statistics', 'last_comment_uid', array('last_comment_uid')); + $t = get_t(); return $t('Updated database to reflect new comment structure'); }