You are here

function bean_update_7010 in Bean (for Drupal 7) 7

Add uid, changed and created to bean table

File

./bean.install, line 429
Bean installation routines

Code

function bean_update_7010(&$sand) {
  $t = get_t();
  $schema = bean_schema();
  db_add_field('bean', 'uid', $schema['bean_revision']['fields']['uid']);
  db_add_field('bean', 'created', $schema['bean_revision']['fields']['created']);
  db_add_field('bean', 'changed', $schema['bean_revision']['fields']['changed']);
  $results = db_query("SELECT bid, uid, created, changed from {bean_revision} GROUP BY bid ORDER BY changed");
  foreach ($results as $row) {
    db_update('bean')
      ->fields(array(
      'uid' => $row->uid,
      'created' => $row->created,
      'changed' => $row->changed,
    ))
      ->condition('bid', $row->bid)
      ->execute();
  }
  return $t('Bean Table updated and data upgraded');
}