You are here

function gdpr_consent_schema in General Data Protection Regulation 7

Implements hook_schema().

File

modules/gdpr_consent/gdpr_consent.install, line 11
Install file for the GDPR Consent module.

Code

function gdpr_consent_schema() {
  $schema = array();
  $schema['gdpr_consent_agreement'] = array(
    'description' => 'Base table for GDPR Consent Agreement entity.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Primary key of the GDPR Consent Agreement entity.',
      ),
      'name' => array(
        'description' => 'The machine-readable name of this consent agreement.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'revision_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The ID of consent agreement\'s default revision.',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Title of the consent agreement.',
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The Unix timestamp of the entity creation time.',
      ),
      'changed' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The Unix timestamp the entity was last edited.',
      ),
      'author_uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => "The {users}.uid of the consent author.",
      ),
      'agreement_type' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Consent agreement\'s type: implicit (0) or explicit (1).',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Entity status.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'foreign keys' => array(
      'author_uid' => array(
        'table' => 'users',
        'columns' => array(
          'author_uid' => 'uid',
        ),
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
      'revision_id' => array(
        'revision_id',
      ),
    ),
    'indexes' => array(
      'author_uid' => array(
        'author_uid',
      ),
      'agreement_type' => array(
        'agreement_type',
      ),
    ),
  );
  $schema['gdpr_consent_agreement_revision'] = array(
    'description' => 'GDPR Consent Agreement entity revisions.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The ID of the GDPR Consent Agreement entity.',
      ),
      'revision_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique revision ID.',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Title of the consent agreement.',
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'A Unix timestamp indicating when this version was created.',
      ),
      'author_uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => "The {users}.uid of the consent author.",
      ),
      'revision_uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => "The {users}.uid of the revising user.",
      ),
      'description' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => FALSE,
        'description' => 'A description of the consent agreement.',
      ),
      'long_description' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => FALSE,
        'description' => 'A long description of the consent agreement.',
      ),
      'agreement_type' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Consent agreement\'s type: implicit or explicit.',
      ),
      'notes' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => FALSE,
        'description' => 'Notes for staff to put their rationale for why they have done this for auditors.',
      ),
      'log' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'The log entry explaining the changes in this version.',
      ),
    ),
    'primary key' => array(
      'revision_id',
    ),
    'indexes' => array(
      'id' => array(
        'id',
      ),
      'revision_uid' => array(
        'revision_uid',
      ),
      'author_uid' => array(
        'author_uid',
      ),
      'agreement_type' => array(
        'agreement_type',
      ),
    ),
    'foreign keys' => array(
      'author_uid' => array(
        'table' => 'users',
        'columns' => array(
          'author_uid' => 'uid',
        ),
      ),
      'revision_uid' => array(
        'table' => 'users',
        'columns' => array(
          'revision_uid' => 'uid',
        ),
      ),
    ),
  );
  return $schema;
}