function workspaces_schema

Same name and namespace in other branches
  1. 11.x core/modules/workspaces/workspaces.install \workspaces_schema()
  2. 10 core/modules/workspaces/workspaces.install \workspaces_schema()
  3. 9 core/modules/workspaces/workspaces.install \workspaces_schema()
  4. 8.9.x core/modules/workspaces/workspaces.install \workspaces_schema()

Implements hook_schema().

File

core/modules/workspaces/workspaces.install, line 19

Code

function workspaces_schema() : array {
  $schema['workspace_association'] = [
    'description' => 'Stores the latest entity revisions tracked by a workspace.',
    'fields' => [
      'workspace' => [
        'type' => 'varchar_ascii',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The workspace ID.',
      ],
      'target_entity_type_id' => [
        'type' => 'varchar_ascii',
        'length' => EntityTypeInterface::ID_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The ID of the associated entity type.',
      ],
      'target_entity_id' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The ID of the associated entity.',
      ],
      'target_entity_id_string' => [
        'type' => 'varchar_ascii',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The string ID of the associated entity.',
      ],
      'target_entity_revision_id' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The revision ID of the associated entity.',
      ],
    ],
    'primary key' => [
      'workspace',
      'target_entity_type_id',
      'target_entity_id',
      'target_entity_id_string',
    ],
    'indexes' => [
      'target_entity_revision_id' => [
        'target_entity_revision_id',
      ],
    ],
  ];
  $schema['workspace_association_revision'] = NestedArray::mergeDeep($schema['workspace_association'], [
    'description' => 'Stores all entity revisions tracked by a workspace.',
    'fields' => [
      'initial_revision' => [
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Whether this entity was created in the workspace.',
      ],
    ],
  ]);
  $schema['workspace_association_revision']['primary key'] = [
    'workspace',
    'target_entity_type_id',
    'target_entity_id',
    'target_entity_id_string',
    'target_entity_revision_id',
  ];
  $schema['workspace_association_revision']['indexes'] = [
    'initial_revision' => [
      'initial_revision',
    ],
  ];
  return $schema;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.