You are here

function mediafront_update_7002 in MediaFront 7

Same name and namespace in other branches
  1. 7.2 mediafront.install \mediafront_update_7002()

File

./mediafront.install, line 90

Code

function mediafront_update_7002() {
  $update = array();

  // Add the new fields to the database.
  db_add_field('mediafront_filefield', 'entity', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_add_field('mediafront_filefield', 'bundle', array(
    'type' => 'text',
    'not null' => FALSE,
  ));

  // Update the current fields.
  $fields = db_select('mediafront_filefield', 'f')
    ->fields('f')
    ->execute();
  while ($field = $fields
    ->fetchObject()) {
    db_update('mediafront_filefield')
      ->fields(array(
      'entity' => 'node',
      'bundle' => $field->node_type,
    ))
      ->condition('fid', $field->fid)
      ->execute();
  }

  // Now drop the node_type field.
  db_drop_field('mediafront_filefield', 'node_type');
  return $update;
}