You are here

function gdpr_tasks_schema in General Data Protection Regulation 7

Implements hook_schema().

File

modules/gdpr_tasks/gdpr_tasks.install, line 11
Install file for the GDPR Tasks module.

Code

function gdpr_tasks_schema() {
  $schema['gdpr_task'] = array(
    'description' => 'The base table for tasks.',
    'fields' => array(
      'id' => array(
        'description' => 'The primary identifier for a task.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {gdpr_task_type} of this task.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'The {languages}.language of this task.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'user_id' => array(
        'description' => 'The {users}.uid that this task is for.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The text status of this task.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the task was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the task was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'complete' => array(
        'description' => 'The Unix timestamp when the task was completed.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'requested_by' => array(
        'description' => 'The {users}.uid that requested this task.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'processed_by' => array(
        'description' => 'The {users}.uid that processed this task.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'foreign keys' => array(
      'task_author' => array(
        'table' => 'users',
        'columns' => array(
          'user_id' => 'uid',
        ),
      ),
      'task_requester' => array(
        'table' => 'users',
        'columns' => array(
          'requested_by' => 'uid',
        ),
      ),
      'task_processor' => array(
        'table' => 'users',
        'columns' => array(
          'processed_by' => 'uid',
        ),
      ),
    ),
  );
  $schema['gdpr_task_type'] = array(
    'description' => 'Stores information about all defined profile types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique profile type ID.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this profile type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this profile type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this profile type in relation to others.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this profile type.',
      ),
      '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;
}