function system_update
Search API
7.x system.install | system_update($old_schema, $new_schema) |
6.x system.install | system_update($old_schema, $new_schema) |
4.x system.install | system_update($old_schema, $new_schema) |
5.x system.install | system_update($old_schema, $new_schema) |
File
- modules/
system/ system.install, line 102 - The install file for the System module
Code
function system_update($old_schema, $new_schema) {
if (intval($old_schema) < 2) {
// We need to make the "watchdog.message" field a longtext instead of just "text".
db_query("ALTER TABLE watchdog MODIFY message LONGTEXT");
fpm("Altered watchdog table to change 'message' to LONGTEXT.");
}
if (intval($old_schema) < 3) {
db_query("ALTER TABLE advising_comments MODIFY `comment` LONGTEXT");
db_query("ALTER TABLE courses MODIFY `title` LONGTEXT,
MODIFY `description` LONGTEXT,
MODIFY `data_entry_comment` LONGTEXT");
db_query("ALTER TABLE draft_courses MODIFY `title` LONGTEXT,
MODIFY `description` LONGTEXT,
MODIFY `data_entry_comment` LONGTEXT");
db_query("ALTER TABLE degree_tracks MODIFY `track_description` LONGTEXT");
db_query("ALTER TABLE draft_degree_tracks MODIFY `track_description` LONGTEXT");
db_query("ALTER TABLE degrees MODIFY `public_note` LONGTEXT,
MODIFY `semester_titles_csv` LONGTEXT,
MODIFY `track_selection_config` LONGTEXT");
db_query("ALTER TABLE draft_degrees MODIFY `public_note` LONGTEXT,
MODIFY `semester_titles_csv` LONGTEXT,
MODIFY `track_selection_config` LONGTEXT");
db_query("ALTER TABLE `groups` MODIFY `public_note` LONGTEXT,
MODIFY `definition` LONGTEXT,
MODIFY `icon_filename` LONGTEXT,
MODIFY `data_entry_comment` LONGTEXT");
db_query("ALTER TABLE draft_groups MODIFY `public_note` LONGTEXT,
MODIFY `definition` LONGTEXT,
MODIFY `icon_filename` LONGTEXT,
MODIFY `data_entry_comment` LONGTEXT");
db_query("ALTER TABLE draft_instructions MODIFY `instruction` LONGTEXT");
db_query("ALTER TABLE `variables` MODIFY `value` LONGTEXT");
db_query("ALTER TABLE `student_priority` MODIFY `results` LONGTEXT");
db_query("ALTER TABLE `user_attributes` MODIFY `value` LONGTEXT");
db_query("ALTER TABLE `user_settings` MODIFY `value` LONGTEXT");
db_query("ALTER TABLE `transfer_courses` MODIFY `description` LONGTEXT");
db_query("ALTER TABLE student_settings MODIFY `settings` LONGTEXT");
db_query("ALTER TABLE student_substitutions MODIFY `sub_remarks` LONGTEXT");
db_query("ALTER TABLE menu_router MODIFY `access_arguments` LONGTEXT,
MODIFY `page_arguments` LONGTEXT,
MODIFY `description` LONGTEXT,
MODIFY `page_settings` LONGTEXT");
db_query("ALTER TABLE modules MODIFY `requires` LONGTEXT,
MODIFY `info` LONGTEXT");
db_query("ALTER TABLE watchdog MODIFY `variables` LONGTEXT,
MODIFY `location` LONGTEXT,
MODIFY `referer` LONGTEXT");
fpm("Altered various system tables to change TEXT to LONGTEXT.");
}
if (intval($old_schema) < 4) {
// We want to add the concept of a "advising_session_token" to the advising_sessions table.
db_query("ALTER TABLE advising_sessions ADD COLUMN `advising_session_token` varchar(255) ");
db_query("ALTER TABLE advising_sessions ADD INDEX (`advising_session_token`) ");
// Assign a unique advising session "token" to every advising session/group of sessions saved at the same time.
$res = db_query("SELECT distinct(posted), student_id FROM advising_sessions");
while ($cur = db_fetch_array($res)) {
$p = $cur ['posted'];
$student_id = $cur ['student_id'];
$token = sha1(mt_rand(0, 99999) . $p . $student_id);
db_query("UPDATE advising_sessions SET advising_session_token = ? WHERE posted = ? AND student_id = ?", array($token, $p, $student_id));
}
} // schema 4
if (intval($old_schema) < 5) {
// Add "delete_flag" to advising_sessions table, and a key for it as well.
db_query("ALTER TABLE advising_sessions ADD COLUMN `delete_flag` tinyint(4) DEFAULT 0 ");
db_query("ALTER TABLE advising_sessions ADD INDEX (`delete_flag`) ");
} // schema 5
if (intval($old_schema) < 6) {
// Add extra indexes to watchdog table for easier reporting.
db_query("ALTER TABLE `watchdog` ADD INDEX (`timestamp`) ");
db_query("ALTER TABLE `watchdog` ADD INDEX (`is_student`) ");
db_query("ALTER TABLE `watchdog` ADD INDEX (`is_faculty`) ");
}
if (intval($old_schema) < 7) {
// Add extra index to tables...
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`is_empty`) ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`posted`) ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`faculty_id`) ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`catalog_year`) ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`is_draft`) ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`is_whatif`) ");
db_query("ALTER TABLE `advising_comments` ADD INDEX (`faculty_id`) ");
db_query("ALTER TABLE `advising_comments` ADD INDEX (`posted`) ");
db_query("ALTER TABLE `advising_comments` ADD INDEX (`term_id`) ");
}
if (intval($old_schema) < 8) {
db_query("ALTER TABLE advising_sessions ADD COLUMN `most_recent_session` tinyint(4) DEFAULT 0 ");
db_query("ALTER TABLE `advising_sessions` ADD INDEX (`most_recent_session`) ");
}
if (intval($old_schema) < 9) {
db_query("ALTER TABLE student_courses ADD COLUMN `course_id` int(11) DEFAULT 0 ");
db_query("ALTER TABLE `student_courses` ADD INDEX (`course_id`) ");
}
if (intval($old_schema) < 10) {
db_query("ALTER TABLE `courses` ADD INDEX (`exclude`) ");
db_query("ALTER TABLE `courses` ADD INDEX (`delete_flag`) ");
db_query("ALTER TABLE `draft_courses` ADD INDEX (`exclude`) ");
db_query("ALTER TABLE `draft_courses` ADD INDEX (`delete_flag`) ");
}
if (intval($old_schema) < 11) {
$dept_val = "";
$res = db_query("SELECT * FROM faculty
GROUP BY department_code
ORDER BY department");
while ($cur = db_fetch_array($res)) {
$key = trim($cur ["department_code"]);
$value = trim($cur ["department"]);
if ($key == "") {
$key = "UNSPECIFIED";
}
//$dept_options[$key] = $dispval;
$dept_val .= $key . " ~ " . $value . "\n";
}
variable_set('departments', $dept_val);
}
if (intval($old_schema) < 12) {
// Adding indexs to student_degrees table.
db_query("ALTER TABLE `student_degrees` ADD INDEX (`major_code`) ");
db_query("ALTER TABLE `student_degrees` ADD INDEX (`delete_flag`) ");
// Remove "department" column from faculty table.
db_query("ALTER TABLE faculty DROP COLUMN `department`");
}
}