'A combined leaderboard of totals across the entire site.', 'fields' => array( 'uid' => array( 'default' => 0, 'description' => 'The {users}.uid that is being ranked on the site-wide leaderboard.', 'not null' => TRUE, 'type' => 'int', ), 'points' => array( 'default' => 0, 'description' => "The {users}.uid's combined achievement point total.", 'not null' => TRUE, 'type' => 'int', ), 'unlocks' => array( 'default' => 0, 'description' => "The {users}.uid's total number of achievement unlocks.", 'not null' => TRUE, 'type' => 'int', ), 'timestamp' => array( 'default' => 0, 'description' => 'The Unix timestamp when the {users}.uid last received an achievement.', 'not null' => TRUE, 'type' => 'int', ), ), 'indexes' => array( 'uid_points' => array('uid', 'points'), 'uid_unlocks' => array('uid', 'unlocks'), 'points_timestamp' => array('points', 'timestamp'), 'unlocks_timestamp' => array('unlocks', 'timestamp'), 'uid_points_unlocks' => array('uid', 'points', 'unlocks'), ), 'primary key' => array('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'] = array( 'description' => 'Maps users to the achievements they have unlocked.', 'fields' => array( 'achievement_id' => array( 'default' => '', 'description' => 'The ID of the achievement the {users}.uid has unlocked.', 'length' => 32, 'not null' => TRUE, 'type' => 'varchar', ), 'rank' => array( 'default' => 0, 'description' => 'The ranking the {users}.uid earned for unlocking this achievement.', 'not null' => TRUE, 'type' => 'int', ), 'uid' => array( 'default' => 0, 'description' => 'The {users}.uid that has unlocked the achievement.', 'not null' => TRUE, 'type' => 'int', ), 'timestamp' => array( 'default' => 0, 'description' => 'The Unix timestamp when the {users}.uid last received an achievement.', 'not null' => TRUE, 'type' => 'int', ), ), 'indexes' => array( 'aid_rank' => array('achievement_id', 'rank'), 'aid_timestamp' => array('achievement_id', 'timestamp'), 'uid_timestamp' => array('uid', 'timestamp'), ), 'primary key' => array('achievement_id', 'uid'), ); // some achievements only trigger over time - after 10 comments, after 50 // page views, etc. this is a simple table for storage of these counters. $schema['achievement_storage'] = array( 'description' => 'Provides a general storage area for statistic collection.', 'fields' => array( 'achievement_id' => array( 'default' => '', 'description' => 'An identifier for the achievement whose data is being collected.', 'length' => 32, 'not null' => TRUE, 'type' => 'varchar', ), 'uid' => array( 'default' => 0, 'description' => 'The {users}.uid that the stored data relates to.', 'not null' => TRUE, 'type' => 'int', ), 'data' => array( 'description' => 'A serialized string of the stored data.', 'not null' => TRUE, 'size' => 'big', 'type' => 'blob', ), ), 'primary key' => array('achievement_id', 'uid'), ); return $schema; }