-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark.install
26 lines (21 loc) · 1.09 KB
/
bookmark.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
* Extend the max_limit to 250 in the name field in the bookmark entity.
*/
function bookmark_update_8001() {
// Update the schema.
$field_table = 'bookmark_field_data';
$field_column = 'name';
$new_length = 255;
// Alter value field length in fields table
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
\Drupal::database()->query("ALTER TABLE `{$field_table}` CHANGE `{$field_column}` `{$field_column}` VARCHAR({$new_length}) DEFAULT NULL");
// Update the field definition.
$manager = \Drupal::entityDefinitionUpdateManager();
$manager->updateEntityType($manager->getEntityType('bookmark'));
/** @var \Drupal\Core\Field\BaseFieldDefinition $name_field_definition */
$name_field_definition = $manager->getFieldStorageDefinition('name', 'bookmark');
$name_field_definition->setSetting('max_length', $new_length);
$manager->updateFieldStorageDefinition($name_field_definition);
}