You are here

function party_schema in Party 8.2

Same name and namespace in other branches
  1. 7 party.install \party_schema()

Implements hook_schema().

File

./party.install, line 11
Contains install hooks for the CRM party module.

Code

function party_schema() {
  $schema['party'] = array(
    'description' => 'Stores Id, name and email for party contacts',
    'fields' => array(
      'pid' => array(
        'description' => 'Primary key for the party.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'A label for the party. This is generated by one of a number of plugins.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => 'No Label Yet',
      ),
      'merged' => array(
        'description' => 'Boolean flag for whether this party has been merged with another',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'merged_party' => array(
        'description' => 'The pid of the party this has been merged into',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'email' => array(
        'description' => 'The primary email address for this party. This is generated based off of the primary field settings.',
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'primary key' => array(
      'pid',
    ),
  );
  $schema['party_party_pieces'] = array(
    'description' => 'Stores relationships between party (types) and party pieces',
    'fields' => array(
      'instance_id' => array(
        'description' => 'Primary key for the party piece instance.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'parent_id' => array(
        'description' => 'The id of the parent party piece instance.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'title' => array(
        'description' => 'The title of this party piece',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'party_type' => array(
        'description' => 'The party type.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'party_piece' => array(
        'description' => 'The party piece type.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'arguments' => array(
        'description' => 'Any extra filters or arguments the party piece should apply. In json format.',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'weight' => array(
        'description' => 'The ordering number of the party piece',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'instance_id',
    ),
  );

  // Connect parties to attached entities.
  $schema['party_attached_entity'] = array(
    'description' => "This links parties to attached entities.",
    'fields' => array(
      'delta' => array(
        'description' => 'The delta of this attached entity, so that every record in the table is unique',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'pid' => array(
        'description' => 'The id of the party entity.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'eid' => array(
        'description' => 'The id of the attached entity.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'data_set' => array(
        'description' => 'The data set this entity falls under.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The type of the attached entity.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'entity_bundle' => array(
        'description' => 'The bundle of the attached entity.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'hat_main' => array(
        'description' => 'Is this the main set for this hat.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'hat' => array(
        'description' => 'The hat this is associated with.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'all',
      ),
    ),
    'indexes' => array(
      'party' => array(
        'pid',
      ),
      'entity' => array(
        'eid',
      ),
    ),
    'primary key' => array(
      'pid',
      'data_set',
      'delta',
    ),
  );
  return $schema;
}