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 22

Code

function workspaces_schema() : Schema {
  $columns = [
    Column::varcharAscii(name: 'workspace', description: 'The workspace ID.', length: 128, notNull: TRUE, default: new StringValue('')),
    Column::varcharAscii(name: 'target_entity_type_id', description: 'The ID of the associated entity type.', length: EntityTypeInterface::ID_MAX_LENGTH, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'target_entity_id', description: 'The ID of the associated entity.', unsigned: TRUE, notNull: TRUE, default: new IntValue(0)),
    Column::varcharAscii(name: 'target_entity_id_string', description: 'The string ID of the associated entity.', length: 128, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'target_entity_revision_id', description: 'The revision ID of the associated entity.', unsigned: TRUE, notNull: TRUE),
  ];
  $workspace_association_table = new Table(name: 'workspace_association', description: 'Stores the latest entity revisions tracked by a workspace.', columns: $columns, primaryKey: new PrimaryKey([
    'workspace',
    'target_entity_type_id',
    'target_entity_id',
    'target_entity_id_string',
  ]), indexes: [
    new Index(name: 'target_entity_revision_id', columns: [
      'target_entity_revision_id',
    ]),
  ]);
  $columns[] = Column::int(name: 'initial_revision', description: 'Whether this entity was created in the workspace.', size: ColumnSize::Tiny, notNull: TRUE, default: new IntValue(0));
  $workspace_association_revision_table = new Table(name: 'workspace_association_revision', description: 'Stores all entity revisions tracked by a workspace.', columns: $columns, primaryKey: new PrimaryKey([
    'workspace',
    'target_entity_type_id',
    'target_entity_id',
    'target_entity_id_string',
    'target_entity_revision_id',
  ]), indexes: [
    new Index(name: 'initial_revision', columns: [
      'initial_revision',
    ]),
  ]);
  return new Schema(type: SchemaDefinitionType::Module, name: 'workspaces', tables: [
    $workspace_association_table,
    $workspace_association_revision_table,
  ]);
}

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