function course_update_6133 in Course 6
Same name and namespace in other branches
- 7.2 course.install \course_update_6133()
- 7 course.install \course_update_6133()
Change schema, so all literal date fields can be NULL with no default.
File
- ./
course.install, line 705 - course.install Install and update functions for Courses.
Code
function course_update_6133() {
$ret = array();
$change = array();
$change['course_enrolment'][] = 'created';
$change['course_enrolment'][] = 'timestamp';
$change['course_enrolment'][] = 'enrol_end';
$change['course_node'][] = 'open';
$change['course_node'][] = 'close';
$change['course_node'][] = 'duration';
$schema = course_schema();
foreach ($change as $table => $fields) {
foreach ($fields as $field) {
// Change schema definition.
db_change_field($ret, $table, $field, $field, $schema[$table]['fields'][$field]);
// Change values to NULL where 0 was stored.
$sql = "UPDATE {{$table}} SET {$field} = NULL WHERE {$field} = 0";
$ret[] = update_sql($sql);
}
}
return $ret;
}