You are here

function restful_token_auth_schema in RESTful 7

Same name and namespace in other branches
  1. 7.2 modules/restful_token_auth/restful_token_auth.install \restful_token_auth_schema()

Implements hook_schema().

File

modules/restful_token_auth/restful_token_auth.install, line 12
Install, update, and uninstall functions for the RESTful token authentication module.

Code

function restful_token_auth_schema() {
  $schema = array();
  $schema['restful_token_auth'] = array(
    'description' => 'The authentication token table.',
    'fields' => array(
      'id' => array(
        'description' => 'The authentication token unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The authentication token type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The user the authentication token belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'name' => array(
        'description' => 'The authentication token name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'token' => array(
        'description' => 'The authentication token security token.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the authentication token was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'expire' => array(
        'description' => 'The Unix timestamp when the authentication token will expire.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'foreign keys' => array(
      'uid' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );

  // Cache bins for Entity-cache module.
  $cache_schema = drupal_get_schema_unprocessed('system', 'cache');
  $types = array(
    'restful_token_auth',
  );
  foreach ($types as $type) {
    $schema["cache_entity_{$type}"] = $cache_schema;
    $schema["cache_entity_{$type}"]['description'] = "Cache table used to store {$type} entity records.";
  }
  return $schema;
}