function farm_log_update_7000 in farmOS 7
Migrate all field_farm_date fields to Log timestamp property.
File
- modules/
farm/ farm_log/ farm_log.install, line 42 - Farm Log install file.
Code
function farm_log_update_7000(&$sandbox) {
/*
* As of January 16th, 2015, the Log module has a timestamp property,
* which has the same goal as the field_farm_date field, so we're
* migrating to that.
*/
// Load info about the field_farm_date field.
$field_info = field_info_field('field_farm_date');
// Copy all timestamps from the field to the property.
$query = "UPDATE {log} l\n INNER JOIN {field_data_field_farm_date} f\n ON l.id = f.entity_id\n AND f.entity_type = 'log'\n SET l.timestamp = f.field_farm_date_value";
db_query($query);
// Iterate through the log bundles that implement this field.
if (!empty($field_info['bundles']['log'])) {
foreach ($field_info['bundles']['log'] as $bundle) {
// Load and delete the field instance.
$field_instance = field_info_instance('log', 'field_farm_date', $bundle);
field_delete_instance($field_instance);
}
}
}