You are here

function user_badges_schema in User Badges 7.4

Same name and namespace in other branches
  1. 6.2 user_badges.install \user_badges_schema()
  2. 6 user_badges.install \user_badges_schema()
  3. 7 user_badges.install \user_badges_schema()
  4. 7.2 user_badges.install \user_badges_schema()
  5. 7.3 user_badges.install \user_badges_schema()

Implements hook_schema().

File

./user_badges.install, line 11
Install for user_badge module

Code

function user_badges_schema() {
  $schema = array();
  $schema['user_badge'] = array(
    'description' => 'User Badge table for Entity',
    'fields' => array(
      'bid' => array(
        'description' => 'Primary key badge id',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'Name for user_badge',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'description' => 'Badge weight for this user',
        'type' => 'int',
        'default' => 0,
      ),
      'created' => array(
        'description' => 'Created timestamp',
        'type' => 'int',
        'not null' => FALSE,
      ),
      'changed' => array(
        'description' => 'Changed timestamp',
        'type' => 'int',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'bid',
    ),
    'indexes' => array(
      'name_idx' => array(
        'name',
      ),
    ),
  );
  $schema['user_badges_assignment'] = array(
    'description' => 'Holds information about badge assignments',
    'fields' => array(
      'uba_id' => array(
        'description' => 'Primary key for this table',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'Foreign key to users table',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'bid' => array(
        'description' => 'Foreign key to bid',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'weight' => array(
        'description' => 'Badge weight for this user',
        'type' => 'int',
        'default' => 0,
      ),
      'type' => array(
        'description' => 'Assignment type: 1 for user, 2 for role',
        'type' => 'int',
        'default' => 1,
      ),
    ),
    'foreign keys' => array(
      'uid' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
      'bid' => array(
        'table' => 'user_badge',
        'columns' => array(
          'bid' => 'bid',
        ),
      ),
    ),
    'primary key' => array(
      'uba_id',
    ),
  );
  return $schema;
}