function course_update_6122 in Course 6
Same name and namespace in other branches
- 7.2 course.install \course_update_6122()
- 7 course.install \course_update_6122()
Migrate and remove old fields that won't be used anymore.
File
- ./
course.install, line 467 - course.install Install and update functions for Courses.
Code
function course_update_6122() {
$ret = array();
// Migrate any passing grade to serialized storage.
$sql = "SELECT * FROM {course_outline}";
$result = db_query($sql);
while ($row = db_fetch_object($result)) {
$row->data = unserialize($row->data);
$row->data['passing_grade'] = $row->passing_grade;
$row->data = serialize($row->data);
db_query("UPDATE {course_outline} SET data = '%s' WHERE snid = %d", $row->data, $row->snid);
}
$deletes = array(
array(
'course_node',
'transcript',
),
array(
'course_node',
'catalog',
),
array(
'course_node',
'outline_custom_titles',
),
array(
'course_outline',
'graded',
),
array(
'course_outline',
'passing_grade',
),
array(
'course_outline',
'payment_required',
),
);
foreach ($deletes as $delete) {
$table = $delete[0];
$column = $delete[1];
if (db_column_exists($table, $column)) {
db_drop_field($ret, $table, $column);
}
}
return $ret;
}