Migrate animal description field via hook_update_n().
This commit is contained in:
parent
e1f1d9dc53
commit
0fa5168501
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Farm livestock install file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Migrate Animal Description field to plain Description field (from farm_fields).
|
||||
*/
|
||||
function farm_livestock_update_7000(&$sandbox) {
|
||||
|
||||
// Revert this module's field_instance Features component.
|
||||
features_revert(array('farm_livestock' => array('field_instance')));
|
||||
|
||||
// If the new description field database tables exist...
|
||||
if (db_table_exists('field_data_field_farm_description') && db_table_exists('field_revision_field_farm_description')) {
|
||||
|
||||
// Copy all descriptions from the old database tables to the new ones.
|
||||
db_query('INSERT INTO {field_data_field_farm_description} SELECT * FROM {field_data_field_farm_animal_description}');
|
||||
db_query('INSERT INTO {field_revision_field_farm_description} SELECT * FROM {field_revision_field_farm_animal_description}');
|
||||
|
||||
// Delete the old field.
|
||||
$field = field_info_instance('farm_asset', 'field_farm_animal_description', 'animal');
|
||||
field_delete_instance($field);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue