You are here

function certificate_update_7006 in Certificate 8.3

Same name and namespace in other branches
  1. 7.3 certificate.install \certificate_update_7006()

Add certificate types.

File

./certificate.install, line 641
Install the Certificate module.

Code

function certificate_update_7006() {
  $schema = array();
  $schema['certificate_type'] = array(
    'description' => 'Stores information about all defined certificate types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique certificate type ID.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this certificate type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this certificate 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_create_table('certificate_type', $schema['certificate_type']);
  drupal_get_schema(NULL, TRUE);
  $certificate_type = array(
    'type' => 'certificate',
    'label' => t('Certificate'),
  );
  drupal_write_record('certificate_type', $certificate_type);
  db_update('certificate')
    ->fields(array(
    'type' => 'certificate',
  ))
    ->execute();
  db_drop_field('certificate_revision', 'type');
  drupal_get_schema(NULL, TRUE);
  entity_info_cache_clear();
}