You are here

function farm_livestock_update_7000 in farmOS 7

Migrate Animal Description field to plain Description field (from farm_fields).

File

modules/farm/farm_livestock/farm_livestock.install, line 44
Farm livestock install file.

Code

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);
  }
}