You are here

function quail_api_schema in Quail API 8

Same name and namespace in other branches
  1. 7 quail_api.install \quail_api_schema()

Implementation of hook_schema().

File

./quail_api.install, line 11
Install file for the quail api.

Code

function quail_api_schema() {
  $schema = array();
  $schema['quail_api_tests'] = [
    'fields' => [
      'id' => [
        'description' => t("A numerical primary key that uniquely represents the test. Any foreign keys should point to this."),
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'size' => 'big',
      ],
      'severity' => [
        'description' => t("This is the numeric representation of the quail test display levels."),
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ],
      'machine_name' => [
        'description' => t("This is the machine-friendly name used by the quail library that represents the test."),
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ],
      'human_name' => [
        'description' => t("This is the human-friendly name used by the quail library that represents the test."),
        'type' => 'text',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => '',
      ],
      'description' => [
        'description' => t("This is the description the test that this row represents."),
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
        'default' => '',
      ],
    ],
    'primary key' => [
      'id',
    ],
    'unique keys' => [
      'machine_name' => [
        'machine_name',
      ],
    ],
  ];

  // mysql often does not support default values on text fields, so remove it.
  if (\Drupal::database()
    ->driver() == 'mysql') {
    unset($schema['quail_api_tests']['fields']['human_name']['default']);
    unset($schema['quail_api_tests']['fields']['description']['default']);
  }
  return $schema;
}