You are here

function search_api_saved_searches_schema in Search API Saved Searches 7

Same name and namespace in other branches
  1. 8 search_api_saved_searches.install \search_api_saved_searches_schema()

Implements hook_schema().

File

./search_api_saved_searches.install, line 12
Install, update and uninstall functions for the Search API saved searches module.

Code

function search_api_saved_searches_schema() {
  $schema['search_api_saved_searches_settings'] = array(
    'description' => 'The "saved searches" settings for a specific index.',
    'fields' => array(
      'id' => array(
        'description' => 'The primary identifier for saved search settings.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'delta' => array(
        'description' => 'The {block}.delta used for these saved searches.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '0',
      ),
      'index_id' => array(
        'description' => 'The {search_api_index}.machine_name this settings record is for.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
      ),
      'enabled' => array(
        'description' => 'A flag indicating whether saved searches for this index are enabled.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
      'options' => array(
        'description' => 'The actual settings for saved searches.',
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => TRUE,
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'index_id' => array(
        'index_id',
      ),
    ),
    'unique keys' => array(
      'delta' => array(
        'delta',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['search_api_saved_search'] = array(
    'description' => 'A saved search that will be periodically executed.',
    'fields' => array(
      'id' => array(
        'description' => 'The primary identifier for a saved search.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The {users}.uid that created this saved search.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'settings_id' => array(
        'description' => 'The {search_api_saved_searches_settings}.delta this saved search uses.',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
      ),
      'enabled' => array(
        'description' => 'The state of this saved search, enabled (1) or not (0).',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'name' => array(
        'description' => 'The displayed name for this saved search.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'mail' => array(
        'description' => 'The mail address that should receive notifications.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the saved search was created.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'last_queued' => array(
        'description' => 'The Unix timestamp when the saved search was last queued.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'last_execute' => array(
        'description' => 'The Unix timestamp when the saved search was last executed.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'notify_interval' => array(
        'description' => 'The interval in which this saved search will be checked for new results, in seconds.',
        'type' => 'int',
        'not null' => FALSE,
      ),
      'query' => array(
        'description' => 'The actual search query to be executed.',
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => TRUE,
      ),
      'options' => array(
        'description' => 'Additional options for this saved search.',
        'type' => 'blob',
        'serialize' => TRUE,
        'not null' => TRUE,
      ),
      'results' => array(
        'description' => 'A comma-separated list of all "old" results for this saved search.',
        'type' => 'text',
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'user' => array(
        'mail',
        'uid',
      ),
      'notify' => array(
        'enabled',
        'notify_interval',
        'last_queued',
        'last_execute',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}