You are here

function _farm_livestock_update_7005_stage1 in farmOS 7

Update 7005 stage 1: Prepare.

See also

farm_livestock_update_7005().

1 call to _farm_livestock_update_7005_stage1()
farm_livestock_update_7005 in modules/farm/farm_livestock/farm_livestock.install
Create group assets for each animal group term, assign animals to new group assets, convert egg logs to harvest logs, and remove old animal groups taxonomy and related features.

File

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

Code

function _farm_livestock_update_7005_stage1(&$sandbox) {

  // If we are not on stage 1, bail.
  if (empty($sandbox['stage']) || $sandbox['stage'] != 1) {
    return;
  }

  // Delete the farm_livestock_eggs module from the {system} table.
  db_query("DELETE FROM {system} WHERE type = 'module' AND name = 'farm_livestock_eggs'");

  // Revert Features to enable the group field on observation logs, and the
  // measure field on quantity field collections.
  $components = array(
    'farm_group' => array(
      'field_base',
      'field_instance',
    ),
    'farm_log_observation' => array(
      'field_instance',
    ),
    'farm_quantity' => array(
      'field_base',
      'field_instance',
    ),
  );
  features_get_modules(NULL, TRUE);
  features_revert($components);

  // We are ready for stage 2.
  $sandbox['#finished'] = 0;
  $sandbox['stage'] = 2;
}