You are here

function course_update_7130 in Course 7.2

Same name and namespace in other branches
  1. 7 course.install \course_update_7130()

Install the new course_enrollment_type table for 7.x-1.3.

File

./course.install, line 1001
course.install Install and update functions for Courses.

Code

function course_update_7130() {
  db_create_table('course_enrollment_type', array(
    'description' => 'Stores information about all defined profile types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique enrollment type ID.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this enrollment type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  ));
  db_add_field('course_enrollment', 'type', array(
    'description' => 'The machine-readable name of this enrollment type.',
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field('course_node', 'enrollment_type', array(
    'description' => 'The machine-readable name of this enrollment type.',
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  ));
  drupal_get_schema(NULL, TRUE);
  $course_enrollment_type = array(
    'type' => 'course_enrollment',
    'label' => t('Course'),
  );
  drupal_write_record('course_enrollment_type', $course_enrollment_type);
  variable_set('course_default_enrollment_type', 'course_enrollment');
  db_update('course_node')
    ->fields(array(
    'enrollment_type' => 'course_enrollment',
  ))
    ->execute();
  db_update('course_enrollment')
    ->fields(array(
    'type' => 'course_enrollment',
  ))
    ->execute();
  return t('Created tables and updated data for course enrollment bundles.');
}