You are here

function certificate_schema in Certificate 7.3

Same name and namespace in other branches
  1. 8.3 certificate.install \certificate_schema()
  2. 6.2 certificate.install \certificate_schema()
  3. 6 certificate.install \certificate_schema()
  4. 7.2 certificate.install \certificate_schema()
  5. 3.x certificate.install \certificate_schema()

Implements hook_schema().

File

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

Code

function certificate_schema() {
  $schema['certificate_node_settings'] = array(
    'description' => 'Stores per-node template settings.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'orientation' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  $schema['certificate_node'] = array(
    'description' => 'Stores per-node certificate settings.',
    'fields' => array(
      'cnid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique identifier for the per-node / per-type template setting.',
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Course node ID.',
      ),
      'mapper' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'The mapper to use.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'The value to match on.',
      ),
      'template' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 256,
        'description' => 'The certificate to deliver on a match.',
      ),
    ),
    'primary key' => array(
      'cnid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  $schema['certificate'] = array(
    'description' => 'Stores certificate information.',
    'fields' => array(
      'cid' => array(
        'description' => 'Primary key',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'Certificate revision ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'title' => array(
        'description' => 'Title',
        'type' => 'varchar',
        'length' => '128',
      ),
      'name' => array(
        'description' => 'Machine Name',
        'type' => 'varchar',
        'length' => '128',
      ),
      'type' => array(
        'description' => 'Certificate type',
        'type' => 'varchar',
        'length' => '255',
      ),
      'orientation' => array(
        'description' => 'Certificate orientation',
        'type' => 'varchar',
        'length' => '255',
      ),
      '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(
      'cid',
    ),
    'foreign keys' => array(
      'certificate_revision' => array(
        'table' => 'certificate_revision',
        'columns' => array(
          'vid' => 'vid',
        ),
      ),
    ),
  );
  $schema['certificate_revision'] = array(
    'description' => 'Holds information about Certificate.',
    'fields' => array(
      'cid' => array(
        'description' => 'Certificate ID',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'Certificate revision ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'Title',
        'type' => 'varchar',
        'length' => '128',
      ),
      'name' => array(
        'description' => 'Machine Name',
        'type' => 'varchar',
        'length' => '128',
      ),
      'orientation' => array(
        'description' => 'Certificate orientation',
        'type' => 'varchar',
        'length' => '255',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the credit awarded was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the credit awarded was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'foreign keys' => array(
      'certificate' => array(
        'table' => 'certificate',
        'columns' => array(
          'cid' => 'cid',
        ),
      ),
    ),
  );
  $schema['certificate_snapshots'] = array(
    'description' => 'Stores snapshots of users certificate for a particular course.',
    'fields' => array(
      'csid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique identifier for the per-user / per-course certificate snapshot.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '{user}.uid of the u.',
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '{node}.nid of the node.',
      ),
      'cid' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 256,
        'description' => 'Template name used for generation.',
      ),
      'date' => array(
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
        'description' => 'Date the certificate was generated.',
      ),
      'snapshot' => array(
        'description' => 'The generated content of the {certificate_snapshots}.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'csid',
    ),
  );
  $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',
      ),
    ),
  );
  return $schema;
}