You are here

function seochecklist_update_6204 in SEO Checklist 6.3

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

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

File

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

Code

function seochecklist_update_6204() {
  $ret = array();
  db_add_field($ret, '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");
  while ($record = db_fetch_object($query)) {
    $record->changed = strtotime($record->date_changed);
    if (!$record->changed) {
      $record->changed = time();
    }
    $ret[] = update_sql("UPDATE {seo_checklist} SET completed = {$record->changed} WHERE id = {$record->id}");
  }
  db_drop_field($ret, 'seo_checklist', 'date_changed');
  db_drop_field($ret, 'seo_checklist', 'option_checked');
  db_drop_field($ret, 'seo_checklist', 'checked_module');
  return $ret;
}