function entity_test_schema

Implements hook_schema().

File

drupal/core/modules/system/tests/modules/entity_test/entity_test.install, line 45
Install, update and uninstall functions for the entity_test module.

Code

function entity_test_schema() {

  // Schema for simple entity.
  $schema['entity_test'] = array(
    'description' => 'Stores entity_test items.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entity-test item ID.',
      ),
      'uuid' => array(
        'description' => 'Unique Key: Universally unique identifier for this entity.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The bundle of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of the original variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'user_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The {users}.uid of the associated user.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );

  // Schema for entity with revisions.
  $schema['entity_test_rev'] = array(
    'description' => 'Stores entity_test_rev items.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entity-test item ID.',
      ),
      'revision_id' => array(
        'description' => 'The current {entity_test_rev_property_revision}.revision_id version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uuid' => array(
        'description' => 'Unique Key: Universally unique identifier for this entity.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The bundle of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of the original variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );
  $schema['entity_test_rev_revision'] = array(
    'description' => 'Stores entity_test_rev item property revisions.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The {entity_test_rev}.id of the test entity.',
      ),
      'revision_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The primary identifier for this version.',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of this variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'user_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The {users}.uid of the associated user.',
      ),
    ),
    'indexes' => array(
      'user_id' => array(
        'user_id',
      ),
    ),
    'foreign keys' => array(
      'user_id' => array(
        'users' => 'uid',
      ),
      'id' => array(
        'entity_test_rev' => 'id',
      ),
    ),
    'primary key' => array(
      'revision_id',
      'id',
      'langcode',
    ),
  );

  // Schema for entity with data table.
  $schema['entity_test_mul'] = array(
    'description' => 'Stores entity_test_mul items.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entity-test item ID.',
      ),
      'uuid' => array(
        'description' => 'Unique Key: Universally unique identifier for this entity.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The bundle of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of the original variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );
  $schema['entity_test_mul_property_data'] = array(
    'description' => 'Stores entity_test_mul item properties.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The {entity_test_mul}.id of the test entity.',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of this variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'default_langcode' => array(
        'description' => 'Boolean indicating whether the current variant is in the original entity language.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ),
      'user_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The {users}.uid of the associated user.',
      ),
    ),
    'indexes' => array(
      'user_id' => array(
        'user_id',
      ),
    ),
    'foreign keys' => array(
      'user_id' => array(
        'users' => 'uid',
      ),
      'id' => array(
        'entity_test_mul' => 'id',
      ),
    ),
    'primary key' => array(
      'id',
      'langcode',
    ),
  );

  // Schema for entity with data table and revisions.
  $schema['entity_test_mulrev'] = array(
    'description' => 'Stores entity_test_mulrev items.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entity-test item ID.',
      ),
      'revision_id' => array(
        'description' => 'The current {entity_test_mulrev_property_revision}.revision_id version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uuid' => array(
        'description' => 'Unique Key: Universally unique identifier for this entity.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The bundle of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of the original variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );
  $schema['entity_test_mulrev_property_data'] = array(
    'description' => 'Stores entity_test_mulrev item properties.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The {entity_test_mulrev}.id of the test entity.',
      ),
      'revision_id' => array(
        'description' => 'The current {entity_test_mulrev_property_revision}.revision_id version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of this variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'default_langcode' => array(
        'description' => 'Boolean indicating whether the current variant is in the original entity language.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'user_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The {users}.uid of the associated user.',
      ),
    ),
    'indexes' => array(
      'user_id' => array(
        'user_id',
      ),
    ),
    'foreign keys' => array(
      'user_id' => array(
        'users' => 'uid',
      ),
      'id' => array(
        'entity_test_mulrev' => 'id',
      ),
    ),
    'primary key' => array(
      'id',
      'langcode',
    ),
  );
  $schema['entity_test_mulrev_property_revision'] = array(
    'description' => 'Stores entity_test_mulrev item property revisions.',
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The {entity_test_mulrev}.id of the test entity.',
      ),
      'revision_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The primary identifier for this version.',
      ),
      'langcode' => array(
        'description' => 'The {language}.langcode of this variant of this test entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'default_langcode' => array(
        'description' => 'Boolean indicating whether the current variant is in the original entity language.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'name' => array(
        'description' => 'The name of the test entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'user_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
        'description' => 'The {users}.uid of the associated user.',
      ),
    ),
    'indexes' => array(
      'user_id' => array(
        'user_id',
      ),
    ),
    'foreign keys' => array(
      'user_id' => array(
        'users' => 'uid',
      ),
      'id' => array(
        'entity_test_mulrev' => 'id',
      ),
    ),
    'primary key' => array(
      'revision_id',
      'id',
      'langcode',
    ),
  );
  return $schema;
}