You are here

function course_update_7145 in Course 7.2

Update certain dates to be NULLable.

File

./course.install, line 1295
course.install Install and update functions for Courses.

Code

function course_update_7145() {
  db_change_field('course_enrollment', 'timestamp', 'timestamp', [
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
    'description' => 'The time the user started the course.',
  ]);
  db_query('UPDATE {course_enrollment} SET timestamp = NULL WHERE timestamp = 0');

  // Records should never be 0, these are likely orphaned if they weren't
  // fixed by course_update_7144();
  db_query('UPDATE {course_enrollment} SET updated = 0 WHERE updated IS NULL');
  db_change_field('course_enrollment', 'updated', 'updated', [
    'type' => 'int',
    'not null' => TRUE,
    'unsigned' => TRUE,
    'description' => 'Date this record was updated.',
  ]);
  db_change_field('course_enrollment', 'enroll_end', 'enroll_end', [
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
    'description' => 'Date enrollment ends.',
  ]);
  db_query('UPDATE {course_enrollment} SET enroll_end = NULL WHERE enroll_end = 0');

  // Records should never be NULL, these are likely orphaned if they weren't
  // fixed by course_update_7144();
  db_query('UPDATE {course_report} SET updated = 0 WHERE updated IS NULL');
  db_change_field('course_report', 'updated', 'updated', [
    'type' => 'int',
    'not null' => TRUE,
    'unsigned' => TRUE,
    'description' => 'Date this record was updated.',
  ]);
}