You are here

function gdpr_consent_field_schema in General Data Protection Regulation 7

Implements hook_field_schema().

File

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

Code

function gdpr_consent_field_schema($field) {
  $columns = array(
    'target_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
    ),
    'target_revision_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
    ),
    'agreed' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'size' => 'tiny',
    ),
    'date' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
    ),
    'user_consenter' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => FALSE,
      'default' => NULL,
      'description' => 'The user uid of the user giving consent',
    ),
    'user_recorder' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => FALSE,
      'default' => NULL,
      'description' => 'The user uid of the user recording the consent',
    ),
    'notes' => array(
      'type' => 'text',
      'size' => 'medium',
      'not null' => FALSE,
    ),
  );
  $indexes = array(
    'target_id' => array(
      'target_id',
    ),
    'target_revision_id' => array(
      'target_revision_id',
    ),
    'agreed' => array(
      'agreed' => 'agreed',
    ),
    'user_consenter' => array(
      'user_consenter' => 'user_consenter',
    ),
    'user_recorder' => array(
      'user_recorder' => 'user_recorder',
    ),
  );
  return array(
    'columns' => $columns,
    'indexes' => $indexes,
    'foreign keys' => array(
      'target_id' => array(
        'table' => 'gdpr_consent_agreement',
        'columns' => array(
          'target_id' => 'id',
        ),
      ),
      'target_revision_id' => array(
        'table' => 'gdpr_consent_agreement_revision',
        'columns' => array(
          'target_revision_id' => 'revision_id',
        ),
      ),
      'user_consenter' => array(
        'table' => 'users',
        'columns' => array(
          'user_consenter' => 'uid',
        ),
      ),
      'user_recorder' => array(
        'table' => 'users',
        'columns' => array(
          'user_recorder' => 'uid',
        ),
      ),
    ),
  );
}