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 83 - The install file for the System module
Code
function system_update($old_schema, $new_schema) {
if ($old_schema <= 1) {
// Add column to the faculty table
db_query("ALTER TABLE faculty
ADD COLUMN department_code varchar(10) AFTER college,
ADD INDEX (department_code)");
}
if ($old_schema < 3) {
// Add an index to the advising_comments table for access_type
db_query("ALTER TABLE advising_comments
ADD INDEX (access_type) ");
}
if ($old_schema < 4) {
// Add college-related tables
db_query("CREATE TABLE `colleges` (
`college_code` varchar(10) ,
`title` varchar(255) ,
PRIMARY KEY (`college_code`)
) ");
db_query("CREATE TABLE `degree_college` (
`major_code` varchar(100) ,
`college_code` varchar(10) ,
PRIMARY KEY (`major_code`),
KEY `college_code` (`college_code`)
) ");
fp_add_message(t("Added college-related tables to database."));
}
if ($old_schema < 5) {
// Update hour fields to be decimal type.
db_query("ALTER TABLE `advised_courses` MODIFY `var_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `student_courses` MODIFY `hours_awarded` DECIMAL(8,4) ");
db_query("ALTER TABLE `student_substitutions` MODIFY `sub_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `courses` MODIFY `min_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `courses` MODIFY `max_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `courses` MODIFY `repeat_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `draft_courses` MODIFY `min_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `draft_courses` MODIFY `max_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `draft_courses` MODIFY `repeat_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `degree_requirements` MODIFY `group_hours_required` DECIMAL(8,4) ");
db_query("ALTER TABLE `draft_degree_requirements` MODIFY `group_hours_required` DECIMAL(8,4) ");
db_query("ALTER TABLE `student_transfer_courses` MODIFY `hours_awarded` DECIMAL(8,4) ");
db_query("ALTER TABLE `transfer_courses` MODIFY `min_hours` DECIMAL(8,4) ");
db_query("ALTER TABLE `transfer_courses` MODIFY `max_hours` DECIMAL(8,4) ");
// Also, expand the varchar fields for students table...
db_query("ALTER TABLE `students` MODIFY `cumulative_hours` varchar(10) ");
db_query("ALTER TABLE `students` MODIFY `gpa` varchar(10) ");
fp_add_message(t("Updated database fields to allow for decimal hours."));
}
if ($old_schema < 6) {
// Add level_code field to relavant tables.
db_query("alter table `student_courses` add column `level_code` VARCHAR(10) ");
db_query("alter table `student_transfer_courses` add column `level_code` VARCHAR(10) ");
// Also add indexes for these fields.
db_query("alter table `student_courses` add index `level_code` (level_code)");
db_query("alter table `student_transfer_courses` add index `level_code` (level_code)");
fp_add_message(t("Updated database fields to allow for level codes per course."));
}
if ($old_schema < 8) {
// We want to add an "extra_data" field to the student_degrees table. This is an optional field, meant to be
// used by module developers. It can be empty, and will not affect the core functioning of FlightPath.
db_query("alter table `student_degrees` add column `extra_data` VARCHAR(255) ");
// Add an index as well...
db_query("alter table `student_degrees` add index `extra_data` (extra_data)");
}
}