diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-31 20:40:42 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-31 20:40:42 +0000 |
commit | 0c8931dd76d066c5332846d478964d1145c5c6c2 (patch) | |
tree | 9ca354fce97a09cfc2cf1846f8f449af26cc86d5 | |
parent | 75a7c31c337127dea4c64d77508d921a7a52889f (diff) | |
download | brdo-0c8931dd76d066c5332846d478964d1145c5c6c2.tar.gz brdo-0c8931dd76d066c5332846d478964d1145c5c6c2.tar.bz2 |
#986992 follow-up by yched, saintiss: Fix to field_sql_storage_update_7001().
-rw-r--r-- | modules/field/modules/field_sql_storage/field_sql_storage.install | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.install b/modules/field/modules/field_sql_storage/field_sql_storage.install index 379459dfc..6bb53bf47 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -136,40 +136,42 @@ function field_sql_storage_update_7001(&$sandbox) { $table = key($sandbox['tables']); $type = array_shift($sandbox['tables']); - // Add the 'entity_type' column. - if (!db_field_exists($table, 'entity_type')) { - $column = array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - 'description' => 'The entity type this data is attached to.', - ); - db_add_field($table, 'entity_type', $column); - - // Populate the 'entity_type' column based on the 'etid' column. - foreach ($sandbox['etids'] as $etid => $entity_type) { - db_update($table) - ->fields(array('entity_type' => $entity_type)) - ->condition('etid', $etid) - ->execute(); + if (db_table_exists($table)) { + // Add the 'entity_type' column. + if (!db_field_exists($table, 'entity_type')) { + $column = array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + 'description' => 'The entity type this data is attached to.', + ); + db_add_field($table, 'entity_type', $column); + + // Populate the 'entity_type' column based on the 'etid' column. + foreach ($sandbox['etids'] as $etid => $entity_type) { + db_update($table) + ->fields(array('entity_type' => $entity_type)) + ->condition('etid', $etid) + ->execute(); + } + + // Index the new column. + db_add_index($table, 'entity_type', array('entity_type')); } - // Index the new column. - db_add_index($table, 'entity_type', array('entity_type')); - } + // Use the 'entity_type' column in the primary key. + db_drop_primary_key($table); + $primary_keys = array( + 'data' => array('entity_type', 'entity_id', 'deleted', 'delta', 'language'), + 'revision' => array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language'), + ); + db_add_primary_key($table, $primary_keys[$type]); - // Use the 'entity_type' column in the primary key. - db_drop_primary_key($table); - $primary_keys = array( - 'data' => array('entity_type', 'entity_id', 'deleted', 'delta', 'language'), - 'revision' => array('entity_type', 'entity_id', 'revision_id', 'deleted', 'delta', 'language'), - ); - db_add_primary_key($table, $primary_keys[$type]); - - // Drop the 'etid' column. - if (db_field_exists($table, 'etid')) { - db_drop_field($table, 'etid'); + // Drop the 'etid' column. + if (db_field_exists($table, 'etid')) { + db_drop_field($table, 'etid'); + } } // Report progress. |