function workspaces_update_11301

Create the 'workspace_association_revision' table.

File

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

Code

function workspaces_update_11301() : void {
  $schema = \Drupal::database()->schema();
  // Create the new workspace_association_revision table.
  if (!$schema->tableExists('workspace_association_revision')) {
    $workspace_association_revision_schema = [
      'description' => 'Stores all 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.',
        ],
        'initial_revision' => [
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'Whether this entity was created in the workspace.',
        ],
      ],
      'primary key' => [
        'workspace',
        'target_entity_type_id',
        'target_entity_id',
        'target_entity_id_string',
        'target_entity_revision_id',
      ],
      'indexes' => [
        'initial_revision' => [
          'initial_revision',
        ],
      ],
    ];
    $schema->createTable('workspace_association_revision', $workspace_association_revision_schema);
  }
}

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