achievements-2.x-dev/achievements.install

achievements.install
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Achievements module.
 */

/**
 * Implements hook_schema().
 */
function achievements_schema() {
  $schema['achievement_totals'] = [
    'description' => 'A combined leaderboard of totals across the entire site.',
    'fields' => [
      'uid' => [
        'default'       => 0,
        'description'   => 'The {users}.uid that is being ranked on the site-wide leaderboard.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'points' => [
        'default'       => 0,
        'description'   => "The {users}.uid's combined achievement point total.",
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'unlocks' => [
        'default'       => 0,
        'description'   => "The {users}.uid's total number of achievement unlocks.",
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'timestamp' => [
        'default'       => 0,
        'description'   => 'The Unix timestamp when the {users}.uid last received an achievement.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'achievement_id' => [
        'default'       => '',
        'description'   => 'The ID of the achievement the {users}.uid has most recently unlocked.',
        'length'        => 32,
        'not null'      => TRUE,
        'type'          => 'varchar',
      ],
    ],
    'indexes' => [
      'uid_points'        => ['uid', 'points'],
      'uid_unlocks'       => ['uid', 'unlocks'],
      'points_timestamp'  => ['points', 'timestamp'],
      'unlocks_timestamp' => ['unlocks', 'timestamp'],
      'uid_points_unlocks' => ['uid', 'points', 'unlocks'],
    ],
    'primary key'       => ['uid'],
  ];

  // This table not only defines what user has unlocked an achievement, but
  // also the rank for each particular unlock. since these ranks never
  // change, the rank is stored right in the table at unlock time.
  $schema['achievement_unlocks'] = [
    'description' => 'Maps users to the achievements they have unlocked.',
    'fields' => [
      'achievement_id'  => [
        'default'       => '',
        'description'   => 'The ID of the achievement the {users}.uid has unlocked.',
        'length'        => 32,
        'not null'      => TRUE,
        'type'          => 'varchar',
      ],
      'rank' => [
        'default'       => 0,
        'description'   => 'The ranking the {users}.uid earned for unlocking this achievement.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'uid' => [
        'default'       => 0,
        'description'   => 'The {users}.uid that has unlocked the achievement.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'timestamp' => [
        'default'       => 0,
        'description'   => 'The Unix timestamp when the {users}.uid last received an achievement.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'seen' => [
        'default'       => 0,
        'description'   => 'A boolean indicating whether the user has been notified of this unlock.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
    ],
    'indexes' => [
      'aid_rank'        => ['achievement_id', 'rank'],
      'aid_timestamp'   => ['achievement_id', 'timestamp'],
      'uid_seen_timestamp' => ['uid', 'seen', 'timestamp'],
      'uid_timestamp'   => ['uid', 'timestamp'],
    ],
    'primary key'       => ['achievement_id', 'uid'],
  ];

  // Some achievements only trigger over time e.g. after 10 comments, after 50
  // Mondays, etc. this is a simple table for storage of these statistics.
  $schema['achievement_storage'] = [
    'description' => 'Provides a general storage area for statistic collection.',
    'fields' => [
      'achievement_id'  => [
        'default'       => '',
        'description'   => 'An identifier for the achievement whose data is being collected.',
        'length'        => 32,
        'not null'      => TRUE,
        'type'          => 'varchar',
      ],
      'uid' => [
        'default'       => 0,
        'description'   => 'The {users}.uid that the stored data relates to.',
        'not null'      => TRUE,
        'type'          => 'int',
      ],
      'data' => [
        'description'   => 'A serialized string of the stored data.',
        'not null'      => TRUE,
        'size'          => 'big',
        'type'          => 'blob',
      ],
    ],
    'primary key'       => ['achievement_id', 'uid'],
  ];

  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function achievements_uninstall() {
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc