You are here

function redhen_engagement_schema in RedHen CRM 7

Implements hook_schema().

File

modules/redhen_engagement/redhen_engagement.install, line 11
RedhenEngagement install file.

Code

function redhen_engagement_schema() {
  $schema = array();
  $schema['redhen_engagement'] = array(
    'description' => 'The base table for redhen engagements.',
    'fields' => array(
      'engagement_id' => array(
        'description' => 'The primary identifier for an engagement.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The type of this engagement.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'The description of this engagement.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'contact_id' => array(
        'description' => 'The unique ID of the contact this engagement applies to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'engagement_score' => array(
        'description' => 'The {redhen_engagement_score}.name of this redhen_engagement.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'entity_id' => array(
        'description' => 'The id of the source entity that triggered this engagement.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'entity_type' => array(
        'description' => 'The entity type of the source entity that triggered this engagement.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'author_uid' => array(
        'description' => 'The uid of the user who created this engagement.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the redhen_engagement was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'engagement_type' => array(
        'type',
      ),
      'engagement_redhen_contact' => array(
        'contact_id',
      ),
      'engagement_author' => array(
        'author_uid',
      ),
      'engagement_engagement_score' => array(
        'engagement_score',
      ),
    ),
    'foreign keys' => array(
      'engagement_redhen_contact' => array(
        'table' => 'redhen_contact',
        'columns' => array(
          'contact_id' => 'contact_id',
        ),
      ),
      'engagement_author' => array(
        'table' => 'users',
        'columns' => array(
          'author_uid' => 'uid',
        ),
      ),
      'engagement_engagement_score' => array(
        'table' => 'redhen_engagement_score',
        'columns' => array(
          'engagement_score' => 'name',
        ),
      ),
    ),
    'primary key' => array(
      'engagement_id',
    ),
  );
  $schema['redhen_engagement_score'] = array(
    'description' => 'The base table for engaement scores.',
    'fields' => array(
      'engagement_score_id' => array(
        'description' => 'The primary identifier for an engagement score.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The label of this engagement score.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The machine-readable name of this engagement score.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'score' => array(
        'description' => 'The numeric score value for this engagement score.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      '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,
      ),
    ),
    'indexes' => array(
      'engagement_score_score' => array(
        'score',
      ),
    ),
    'primary key' => array(
      'engagement_score_id',
    ),
  );
  return $schema;
}