You are here

function webform_validation_schema in Webform Validation 7

Same name and namespace in other branches
  1. 6 webform_validation.install \webform_validation_schema()

Implements hook_schema().

File

./webform_validation.install, line 11
Webform_validation installation file.

Code

function webform_validation_schema() {
  $schema['webform_validation_rule'] = array(
    'description' => 'Stores rule definitions',
    'fields' => array(
      'ruleid' => array(
        'type' => 'serial',
        'description' => 'Unique identifier for a rule',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'rulename' => array(
        'type' => 'varchar',
        'description' => 'Name for the rule',
        'not null' => TRUE,
        'default' => '',
        'length' => 255,
      ),
      'nid' => array(
        'type' => 'int',
        'description' => 'The webform {node}.nid',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ),
      'validator' => array(
        'type' => 'varchar',
        'description' => 'The validator key',
        'not null' => TRUE,
        'default' => '',
        'length' => 255,
      ),
      'data' => array(
        'type' => 'text',
        'description' => 'Additional rule data',
        'not null' => FALSE,
      ),
      'error_message' => array(
        'type' => 'text',
        'description' => 'Rule error message',
        'not null' => FALSE,
      ),
      'negate' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'description' => 'Validate the inverse of the rule',
        'not null' => TRUE,
        'default' => 0,
      ),
      'weight' => array(
        'description' => 'Weight of the rule order.',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => FALSE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'ruleid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  $schema['webform_validation_rule_components'] = array(
    'description' => 'Stores components linked to a rule',
    'fields' => array(
      'ruleid' => array(
        'type' => 'int',
        'description' => 'Unique identifier for a rule',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ),
      'cid' => array(
        'type' => 'int',
        'description' => 'The webform component id',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ),
    ),
    'primary key' => array(
      'ruleid',
      'cid',
    ),
  );
  return $schema;
}