You are here

farm_water_test.install in farmOS 7

Farm water test install.

File

modules/farm/farm_water/farm_water_test/farm_water_test.install
View source
<?php

/**
 * @file
 * Farm water test install.
 */

/**
 * Migrate water test sample points to field_farm_geofield.
 */
function farm_water_test_update_7000(&$sandbox) {

  // Define table mappings.
  $table_mappings = array(
    'field_data_field_farm_water_sample_points' => 'field_data_field_farm_geofield',
    'field_revision_field_farm_water_sample_points' => 'field_revision_field_farm_geofield',
  );

  // Check to be sure that the tables exist. If not, bail.
  foreach ($table_mappings as $old => $new) {
    $tables = array(
      $old,
      $new,
    );
    foreach ($tables as $table) {
      if (!db_table_exists($table)) {
        throw new DrupalUpdateException('Database table not found: ' . $table . '. Aborting update.');
      }
    }
  }

  // Migrate data.
  foreach ($table_mappings as $old => $new) {
    db_query('INSERT INTO {' . $new . '} SELECT * FROM {' . $old . '}');
  }

  // Delete the old field instance.
  $field = field_info_instance('log', 'field_farm_water_sample_points', 'farm_water_test');
  field_delete_instance($field);
}

Functions

Namesort descending Description
farm_water_test_update_7000 Migrate water test sample points to field_farm_geofield.