diff --git a/relation_endpoint.install b/relation_endpoint.install
index 3b76ee3..8f5de3f 100644
--- a/relation_endpoint.install
+++ b/relation_endpoint.install
@@ -65,3 +65,37 @@ function relation_endpoint_update_7001() {
     db_add_index($table, 'endpoints_r_index', array('endpoints_r_index'));
   }
 }
+
+/**
+ * Fix indexes on tables. Despite update 7001 some sites still have their indexes out of sync. 
+ * Specifically some sites have the indexes in the wrong order. This fixes the order of the indexes.
+ */
+function relation_endpoint_update_7002() {
+  // Same index operations are performed to data and revision tables
+  foreach (array('field_data_endpoints', 'field_revision_endpoints') as $table) {
+    // Do not touch any indexes if field data table doesn't exist. This might
+    // happen if there aren't any relation types created yet.
+    if (!db_table_exists($table)) {
+      continue;
+    }
+
+    // Drop all indexes to recreate in correct order
+    if (db_index_exists($table, 'endpoints_relation')) {
+      db_drop_index($table, 'endpoints_relation');
+    }
+    if (db_index_exists($table, 'endpoints_entity_type')) {
+      db_drop_index($table, 'endpoints_entity_type');
+    }
+    if (db_index_exists($table, 'endpoints_entity_id')) {
+      db_drop_index($table, 'endpoints_entity_id');
+    }
+    if (db_index_exists($table, 'endpoints_r_index')) {
+      db_drop_index($table, 'endpoints_r_index');
+    }
+
+    // Recreate in the correct order
+    db_add_index($table, 'endpoints_entity_type', array('endpoints_entity_type'));
+    db_add_index($table, 'endpoints_entity_id', array('endpoints_entity_id'));
+    db_add_index($table, 'endpoints_r_index', array('endpoints_r_index'));
+  }
+}
