You are here

function restful_schema in RESTful 7.2

Same name and namespace in other branches
  1. 7 restful.install \restful_schema()

Implements hook_schema().

File

./restful.install, line 11
Install, update, and uninstall functions for the RESTful module.

Code

function restful_schema() {
  $schema = array();
  $schema['cache_restful'] = drupal_get_schema_unprocessed('system', 'cache');

  // Rate limit entity base table.
  $schema['restful_rate_limit'] = array(
    'description' => 'Rate limit base table',
    'fields' => array(
      'rlid' => array(
        'description' => 'The rate limit unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event' => array(
        'description' => 'The event name.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'identifier' => array(
        'description' => 'The user & request identifier.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'timestamp' => array(
        'description' => 'The Unix timestamp when the rate limit window started.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'expiration' => array(
        'description' => 'The Unix timestamp when the rate limit window expires.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'hits' => array(
        'description' => 'The number of hits.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'identifier' => array(
        'identifier',
      ),
    ),
    'indexes' => array(
      'rate_limit_identifier' => array(
        'identifier',
      ),
    ),
    'primary key' => array(
      'rlid',
    ),
  );

  // Cache fragment entity base table.
  $schema['restful_cache_fragment'] = array(
    'description' => 'Cache fragment base table',
    'fields' => array(
      'tid' => array(
        'description' => 'The cache fragment unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The type of the cache fragment, e.g "entity_id".',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'description' => 'The value for the tag. Example: 182.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'hash' => array(
        'description' => 'The hash used as a cache ID.',
        'type' => 'char',
        'length' => 40,
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'indexes' => array(
      'cache_fragment_hash' => array(
        'hash',
      ),
    ),
    'unique keys' => array(
      'hash_key_val' => array(
        'type',
        'value',
        'hash',
      ),
    ),
    'primary key' => array(
      'tid',
    ),
  );
  return $schema;
}