function workspace_update_8103 in Workspace 8
Add the replication_status.
File
- ./
workspace.install, line 74 - Install, update and uninstall functions for the workspace module.
Code
function workspace_update_8103() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
// Add the replication status field to the replication entity type.
$replication_status = BaseFieldDefinition::create('boolean')
->setLabel(new TranslatableMarkup('Replication status'))
->setDescription(new TranslatableMarkup('The status of the replication.'))
->setRequired(TRUE)
->setDefaultValue(Replication::FAILED)
->setInitialValue(Replication::FAILED);
$definition_update_manager
->installFieldStorageDefinition('replication_status', 'replication', 'workspace', $replication_status);
// Set the replication_status.
$entity_type = $definition_update_manager
->getEntityType('replication');
\Drupal::database()
->update($entity_type
->getBaseTable())
->fields([
'replication_status' => Replication::REPLICATED,
])
->isNotNull('replicated')
->execute();
}