diff --git a/votingapi.install b/votingapi.install
index 7a01065..b68c782 100644
--- a/votingapi.install
+++ b/votingapi.install
@@ -98,12 +98,70 @@ function votingapi_update_7202() {
  * Renaming the 'content_type' and 'content_id' columns to entity_type and entity_id.
  * Reduces confusion about 'content types' versus 'node types'.
  */
-function votingapi_update_7201() {
-  db_change_field('votingapi_vote', 'content_type', 'entity_type', array('type' => 'varchar', 'length' => 64));
-  db_change_field('votingapi_vote', 'content_id', 'entity_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+function votingapi_update_7201() {
+  // Remove all existing indexes.
+  if (db_index_exists('votingapi_vote', 'content_uid')) {
+    db_drop_index('votingapi_vote', 'content_uid');
+  }
+  if (db_index_exists('votingapi_vote', 'content_uid_2')) {
+    db_drop_index('votingapi_vote', 'content_uid_2');
+  }
+  if (db_index_exists('votingapi_vote', 'content_source')) {
+    db_drop_index('votingapi_vote', 'content_source');
+  }
+  if (db_index_exists('votingapi_vote', 'content_value_tag')) {
+    db_drop_index('votingapi_vote', 'content_value_tag');
+  }
+  if (db_index_exists('votingapi_cache', 'content')) {
+    db_drop_index('votingapi_cache', 'content');
+  }
+  if (db_index_exists('votingapi_cache', 'content_function')) {
+    db_drop_index('votingapi_cache', 'content_function');
+  }
+  if (db_index_exists('votingapi_cache', 'content_tag_func')) {
+    db_drop_index('votingapi_cache', 'content_tag_func');
+  }
+  if (db_index_exists('votingapi_cache', 'content_vtype_tag')) {
+    db_drop_index('votingapi_cache', 'content_vtype_tag');
+  }
+  if (db_index_exists('votingapi_cache', 'content_vtype_tag_func')) {
+    db_drop_index('votingapi_cache', 'content_vtype_tag_func');
+  }
+
+  // Rename 'content_type' and 'content_id' columns to entity_type and entity_id.
+  if (db_field_exists('votingapi_vote', 'content_type')) {
+    db_change_field('votingapi_vote', 'content_type', 'entity_type', array('type' => 'varchar', 'length' => 64));
+  }
+  if (db_field_exists('votingapi_vote', 'content_id')) {
+    db_change_field('votingapi_vote', 'content_id', 'entity_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  }
+  if (db_field_exists('votingapi_cache', 'content_type')) {
+    db_change_field('votingapi_cache', 'content_type', 'entity_type', array('type' => 'varchar', 'length' => 64));
+  }
+  if (db_field_exists('votingapi_cache', 'content_id')) {
+    db_change_field('votingapi_cache', 'content_id', 'entity_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  }
+
+  // Fix field lengths.
+  db_change_field('votingapi_vote', 'entity_type', 'entity_type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'node'));
+  db_change_field('votingapi_vote', 'value_type', 'value_type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'percent'));
+  db_change_field('votingapi_vote', 'tag', 'tag', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'));
+
+  db_change_field('votingapi_cache', 'entity_type', 'entity_type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'node'));
+  db_change_field('votingapi_cache', 'value_type', 'value_type', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'percent'));
+  db_change_field('votingapi_cache', 'tag', 'tag', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'));
+
+  // Recreate the indexes.
+  db_add_index('votingapi_vote', 'content_uid', array('entity_type', 'entity_id', 'uid'));
+  db_add_index('votingapi_vote', 'content_uid_2', array('entity_type', 'uid'));
+  db_add_index('votingapi_vote', 'content_source', array('entity_type', 'entity_id', 'vote_source'));
+  db_add_index('votingapi_vote', 'content_value_tag', array('entity_type', 'entity_id', 'value_type', 'tag'));
 
-  db_change_field('votingapi_cache', 'content_type', 'entity_type', array('type' => 'varchar', 'length' => 64));
-  db_change_field('votingapi_cache', 'content_id', 'entity_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_index('votingapi_cache', 'content', array('entity_type', 'entity_id'));
+  db_add_index('votingapi_cache', 'content_function', array('entity_type', 'entity_id', 'function'));
+  db_add_index('votingapi_cache', 'content_tag_func', array('entity_type', 'entity_id', 'tag', 'function'));
+  db_add_index('votingapi_cache', 'content_vtype_tag', array('entity_type', 'entity_id', 'value_type', 'tag'));
+  db_add_index('votingapi_cache', 'content_vtype_tag_func', array('entity_type', 'entity_id', 'value_type', 'tag', 'function'));
 
   return t('Updated VotingAPI table structure.');
 }
