<?php

/**
 * @file
 * Manifest module install file.
 */

/**
 * Implements hook_schema().
 */
function manifest_schema() {
  $schema['manifest_user'] = array(
    'description' => 'Store the users that are in manifest.',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The User ID',
      ),
      'manifest' => array(
        'description' => 'The manifest this entry belongs to.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'A Unix timestamp indicating when this record was created.',
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('uid', 'manifest'),
  );
  $schema['manifest_role'] = array(
    'description' => 'Store the roles that are in manifest.',
    'fields' => array(
      'rid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The Role ID',
      ),
      'manifest' => array(
        'description' => 'The manifest this entry belongs to.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'A Unix timestamp indicating when this record was created.',
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('rid', 'manifest'),
  );
  $schema['manifest_ip'] = array(
    'description' => 'Store the IP addresses that are in manifest.',
    'fields' => array(
      'ip1' => array(
        'type' => 'int',
        'size' => 'big',
        'not null' => TRUE,
        'description' => 'The User IP address, or range start.',
      ),
      'ip2' => array(
        'type' => 'int',
        'size' => 'big',
        'not null' => TRUE,
        'description' => 'The IP range end.',
      ),
      'manifest' => array(
        'description' => 'The manifest this entry belongs to.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'A Unix timestamp indicating when this record was created.',
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('ip1', 'ip2', 'manifest'),
  );
  $schema['manifest'] = array(
    'description' => 'Store the basic settings for a manifest.',
    'fields' => array(
      'name' => array(
        'description' => 'The machine-readable name of this manifest.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'settings' => array(
        'description' => 'Settings for this manifest.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array('name'),
  );
  $schema['manifest_config'] = array(
    'description' => 'Store the config for a manifest. Only stores integer values.',
    'fields' => array(
      'manifest' => array(
        'description' => 'The machine-readable name of the manifest.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'field' => array(
        'description' => 'The machine-readable name of the field.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'delta' => array(
        'description' => 'Delta for this entry.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'value' => array(
        'description' => 'Value for this entry.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('manifest', 'field', 'delta'),
  );
  return $schema;
}