function commerce_order_update_8214 in Commerce Core 8.2
Add the 'version' field to 'commerce_order' entities.
File
- modules/
order/ commerce_order.install, line 276 - Install, update and uninstall functions for the Order module.
Code
function commerce_order_update_8214() {
$storage_definition = BaseFieldDefinition::create('integer')
->setLabel(t('Version'))
->setDescription(t('The order version number, it gets incremented on each save.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE)
->setDefaultValue(0)
->setInitialValue(1);
$update_manager = \Drupal::entityDefinitionUpdateManager();
$update_manager
->installFieldStorageDefinition('version', 'commerce_order', 'commerce_order', $storage_definition);
return t('The order version number field was created.');
}