You are here

function node_accessibility_schema in Node Accessibility 7

Same name and namespace in other branches
  1. 8 node_accessibility.install \node_accessibility_schema()

Implementation of hook_schema().

File

./node_accessibility.install, line 11
Install file for node accessibility.

Code

function node_accessibility_schema() {
  $schema = array();
  $schema['node_accessibility_problems'] = array(
    'description' => st("Node validation problem statistics."),
    'fields' => array(
      'id' => array(
        'description' => st("The primary key used to represent this problem."),
        'type' => 'serial',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => st("The node's ID from {node}.nid."),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'vid' => array(
        'description' => st("The node's version ID from {node}.vid."),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'test_id' => array(
        'description' => st("The numeric ID from {quail_api_tests}.id, representing a specific error."),
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'line' => array(
        'description' => st("The line number in which the error happened."),
        'type' => 'int',
        'size' => 'normal',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'element' => array(
        'description' => st("A snippet of the code that failed validation."),
        'type' => 'text',
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'foreign keys' => array(
      'nid' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'error_id' => array(
        'table' => 'quail_api_errors',
        'columns' => array(
          'id' => 'id',
        ),
      ),
    ),
  );

  // workaround mysql's violation of the SQL standard in a way that does not break standards-compliant databases.
  // @see https://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html
  // @see https://bugs.mysql.com/bug.php?id=25520
  // @see https://drupal.org/node/1401782
  // @see https://drupal.org/node/143881
  if (db_driver() == 'mysql') {
    unset($schema['node_accessibility_problems']['fields']['element']['default']);
  }
  return $schema;
}