workspaces.install
Same filename and directory in other branches
Contains install, update and uninstall functions for the Workspaces module.
File
-
core/
modules/ workspaces/ workspaces.install
View source
<?php
/**
* @file
* Contains install, update and uninstall functions for the Workspaces module.
*/
use Drupal\Core\Database\SchemaDefinition\Column;
use Drupal\Core\Database\SchemaDefinition\ColumnSize;
use Drupal\Core\Database\SchemaDefinition\Index;
use Drupal\Core\Database\SchemaDefinition\IntValue;
use Drupal\Core\Database\SchemaDefinition\PrimaryKey;
use Drupal\Core\Database\SchemaDefinition\Schema;
use Drupal\Core\Database\SchemaDefinition\SchemaDefinitionType;
use Drupal\Core\Database\SchemaDefinition\StringValue;
use Drupal\Core\Database\SchemaDefinition\Table;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_schema().
*/
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,
]);
}
/**
* Implements hook_update_last_removed().
*/
function workspaces_update_last_removed() : int {
return 11303;
}
/**
* Implements hook_update_dependencies().
*/
function workspaces_update_dependencies() : array {
// The workspaces updates must run after the router table is
// updated since it triggers route rebuilds due to the module install.
$dependencies['workspaces'][11102] = [
'system' => 11201,
];
return $dependencies;
}
Functions
| Title | Deprecated | Summary |
|---|---|---|
| workspaces_schema | Implements hook_schema(). | |
| workspaces_update_dependencies | Implements hook_update_dependencies(). | |
| workspaces_update_last_removed | Implements hook_update_last_removed(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.