You are here

function seochecklist_update_6204 in SEO Checklist 7.3

Same name and namespace in other branches
  1. 6.3 seochecklist.install \seochecklist_update_6204()

Convert the date_changed and option_checked fields into one UNIX completed field.

File

./seochecklist.install, line 112
Install, update and uninstall functions for the seochecklist module.

Code

function seochecklist_update_6204() {
  $ret = array();
  db_add_field('seo_checklist', 'completed', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'description' => 'UNIX timestamp of when this task was completed.',
  ));
  $query = db_query("SELECT id, date_changed FROM {seo_checklist} WHERE option_checked <> 0");
  foreach ($query as $record) {
    $record->changed = strtotime($record->date_changed);
    if (!$record->changed) {
      $record->changed = time();
    }
    $ret[] = db_query("UPDATE {seo_checklist} SET completed = {$record->changed} WHERE id = {$record->id}");
  }
  db_drop_field('seo_checklist', 'date_changed');
  db_drop_field('seo_checklist', 'option_checked');
  db_drop_field('seo_checklist', 'checked_module');

  //return $ret;
}