You are here

function emvideo_update_6013 in Embedded Media Field 6.2

Same name and namespace in other branches
  1. 6.3 contrib/emvideo/emvideo.install \emvideo_update_6013()
  2. 6 contrib/emvideo/emvideo.install \emvideo_update_6013()

Add a duration column to existing fields.

File

contrib/emvideo/emvideo.install, line 333
Installation, configuration, and removal of the emvideo module.

Code

function emvideo_update_6013() {
  $ret = _emvideo_update_reset_cache();
  include_once drupal_get_path('module', 'content') . '/includes/content.admin.inc';
  content_clear_type_cache(TRUE);

  // Build a list of fields that need data updating.
  $fields = array();
  foreach (content_types_install() as $type_name => $type_fields) {
    foreach ($type_fields as $field) {
      if ($field['module'] == 'emvideo') {

        // We only process a given field once.
        $fields[$field['field_name']] = $field;
      }
    }
  }

  // Update database storage (add data column, remove description, set NOT NULL).
  foreach ($fields as $field) {
    $new_field = $field;
    unset($field['duration']);
    content_alter_db($field, $new_field);
    $ret[] = array(
      'query' => t('Added duration to the %field field.', array(
        '%field' => $field['field_name'],
      )),
      'success' => TRUE,
    );
  }
  content_associate_fields('emvideo');
  $ret[] = update_sql("DELETE FROM {cache}");
  return $ret;
}