function course_update_6135 in Course 7
Same name and namespace in other branches
- 6 course.install \course_update_6135()
- 7.2 course.install \course_update_6135()
Naming conventions update.
File
- ./
course.install, line 876 - course.install Install and update functions for Courses.
Code
function course_update_6135() {
$ret = array();
// Change primary keys to int (so we can drop the primary key).
db_change_field('course_outline', 'snid', 'snid', array(
'type' => 'int',
));
db_change_field('course_outline_fulfillment', 'sfid', 'sfid', array(
'type' => 'int',
));
// Drop old PK.
db_drop_primary_key('course_outline');
db_drop_primary_key('course_outline_fulfillment');
// Drop affected indexes.
db_drop_unique_key('course_outline_fulfillment', 'snid_uid');
db_drop_index('course_outline_fulfillment', 'snid');
// Rename columns, add back PK.
db_change_field('course_outline', 'snid', 'coid', array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
), array(
'primary key' => array(
'coid',
),
));
db_change_field('course_outline_fulfillment', 'sfid', 'cofid', array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
), array(
'primary key' => array(
'cofid',
),
));
db_change_field('course_outline_fulfillment', 'snid', 'coid', array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
));
// Change requirement_type/requirement_component fields.
db_change_field('course_outline', 'requirement_type', 'module', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
));
db_change_field('course_outline', 'requirement_component', 'object_type', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
));
// Add keys back.
db_add_unique_key('course_outline_fulfillment', 'coid_uid', array(
'coid',
'uid',
));
db_add_index('course_outline_fulfillment', 'coid', array(
'coid',
));
// Update crid to match schema.
db_change_field('course_report', 'crid', 'crid', array(
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
));
course_update_uuid();
return t('Updated schema naming conventions.');
}