You are here

function restful_schema in RESTful 7

Same name and namespace in other branches
  1. 7.2 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',
    ),
  );
  return $schema;
}