diff -u b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php --- b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php +++ b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity\Schema; +use Drupal\Core\Database\Connection; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityManagerInterface; @@ -45,6 +46,20 @@ protected $schema; /** + * The database connection to be used. + * + * @var \Drupal\Core\Database\Connection + */ + protected $database; + + /** + * A callable to invoke at the end of getEntitySchema(). + * + * @var callable|NULL + */ + protected $entitySchemaCustomizer; + + /** * Constructs a ContentEntitySchemaHandler. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -53,11 +68,17 @@ * The entity type. * @param \Drupal\Core\Entity\ContentEntityDatabaseStorage $storage * The storage of the entity type. This must be an SQL-based storage. + * @param \Drupal\Core\Database\Connection $database + * The database connection to be used. + * @param callable|NULL $entity_schema_customizer + * (optional) A callable to invoke at the end of getEntitySchema(). */ - public function __construct(EntityManagerInterface $entity_manager, ContentEntityTypeInterface $entity_type, ContentEntityDatabaseStorage $storage) { + public function __construct(EntityManagerInterface $entity_manager, ContentEntityTypeInterface $entity_type, ContentEntityDatabaseStorage $storage, Connection $database, callable $entity_schema_customizer = NULL) { $this->entityType = $entity_type; $this->fieldStorageDefinitions = $entity_manager->getFieldStorageDefinitions($entity_type->id()); $this->storage = $storage; + $this->database = $database; + $this->entitySchemaCustomizer = $entity_schema_customizer; } /** @@ -125,6 +146,10 @@ $this->processRevisionDataTable($schema[$tables['revision_data_table']]); } + // Perform additional customizations. + if (isset($this->entitySchemaCustomizer)) { + $schema = call_user_func($this->entitySchemaCustomizer, $schema); + } $this->schema[$entity_type_id] = $schema; } reverted: --- b/core/modules/aggregator/src/FeedSchemaHandler.php +++ /dev/null @@ -1,41 +0,0 @@ - array(array('url', 255)), - 'aggregator_feed__queued' => array('queued'), - ); - $schema['aggregator_feed']['unique keys'] += array( - 'aggregator_feed__title' => array('title'), - ); - - return $schema; - } - -} diff -u b/core/modules/aggregator/src/FeedStorage.php b/core/modules/aggregator/src/FeedStorage.php --- b/core/modules/aggregator/src/FeedStorage.php +++ b/core/modules/aggregator/src/FeedStorage.php @@ -7,8 +7,8 @@ namespace Drupal\aggregator; -use Drupal\aggregator\FeedInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; /** * Controller class for aggregator's feeds. @@ -23,7 +23,22 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new FeedSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['aggregator_feed']['fields']['url']['not null'] = TRUE; + $schema['aggregator_feed']['fields']['queued']['not null'] = TRUE; + $schema['aggregator_feed']['fields']['title']['not null'] = TRUE; + + $schema['aggregator_feed']['indexes'] += array( + 'aggregator_feed__url' => array(array('url', 255)), + 'aggregator_feed__queued' => array('queued'), + ); + $schema['aggregator_feed']['unique keys'] += array( + 'aggregator_feed__title' => array('title'), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/aggregator/src/ItemSchemaHandler.php +++ /dev/null @@ -1,41 +0,0 @@ - array('timestamp'), - ); - $schema['aggregator_item']['foreign keys'] += array( - 'aggregator_item__aggregator_feed' => array( - 'table' => 'aggregator_feed', - 'columns' => array('fid' => 'fid'), - ), - ); - - return $schema; - } - -} diff -u b/core/modules/aggregator/src/ItemStorage.php b/core/modules/aggregator/src/ItemStorage.php --- b/core/modules/aggregator/src/ItemStorage.php +++ b/core/modules/aggregator/src/ItemStorage.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\Query\QueryInterface; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; /** * Controller class for aggregators items. @@ -23,7 +24,22 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new ItemSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['aggregator_item']['fields']['timestamp']['not null'] = TRUE; + + $schema['aggregator_item']['indexes'] += array( + 'aggregator_item__timestamp' => array('timestamp'), + ); + $schema['aggregator_item']['foreign keys'] += array( + 'aggregator_item__aggregator_feed' => array( + 'table' => 'aggregator_feed', + 'columns' => array('fid' => 'fid'), + ), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/block_content/src/BlockContentSchemaHandler.php +++ /dev/null @@ -1,35 +0,0 @@ - array('info', 'langcode'), - ); - - return $schema; - } - -} diff -u b/core/modules/block_content/src/BlockContentStorage.php b/core/modules/block_content/src/BlockContentStorage.php --- b/core/modules/block_content/src/BlockContentStorage.php +++ b/core/modules/block_content/src/BlockContentStorage.php @@ -8,6 +8,7 @@ namespace Drupal\block_content; use Drupal\Core\Entity\ContentEntityDatabaseStorage; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; /** * Provides storage for the 'block_content' entity type. @@ -19,7 +20,16 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new BlockContentSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['block_content_field_data']['fields']['info']['not null'] = TRUE; + + $schema['block_content_field_data']['unique keys'] += array( + 'block_content__info' => array('info', 'langcode'), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/comment/src/CommentSchemaHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - array('pid', 'status'), - 'comment__num_new' => array( - 'entity_id', - 'entity_type', - 'comment_type', - 'status', - 'created', - 'cid', - 'thread', - ), - 'comment__entity_langcode' => array( - 'entity_id', - 'entity_type', - 'comment_type', - 'default_langcode', - ), - 'comment__created' => array('created'), - ); - $schema['comment_field_data']['foreign keys'] += array( - 'comment__author' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ); - - return $schema; - } - -} diff -u b/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php --- b/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -323,7 +324,41 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new CommentSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['comment_field_data']['fields']['created']['not null'] = TRUE; + $schema['comment_field_data']['fields']['thread']['not null'] = TRUE; + + unset($schema['comment_field_data']['indexes']['comment_field__pid__target_id']); + unset($schema['comment_field_data']['indexes']['comment_field__entity_id__target_id']); + $schema['comment_field_data']['indexes'] += array( + 'comment__status_pid' => array('pid', 'status'), + 'comment__num_new' => array( + 'entity_id', + 'entity_type', + 'comment_type', + 'status', + 'created', + 'cid', + 'thread', + ), + 'comment__entity_langcode' => array( + 'entity_id', + 'entity_type', + 'comment_type', + 'default_langcode', + ), + 'comment__created' => array('created'), + ); + $schema['comment_field_data']['foreign keys'] += array( + 'comment__author' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/file/src/FileSchemaHandler.php +++ /dev/null @@ -1,43 +0,0 @@ - array('status'), - 'file__changed' => array('changed'), - ); - $schema['file_managed']['unique keys'] += array( - 'file__uri' => array('uri'), - ); - - return $schema; - } - -} diff -u b/core/modules/file/src/FileStorage.php b/core/modules/file/src/FileStorage.php --- b/core/modules/file/src/FileStorage.php +++ b/core/modules/file/src/FileStorage.php @@ -8,6 +8,7 @@ namespace Drupal\file; use Drupal\Core\Entity\ContentEntityDatabaseStorage; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; /** * File storage for files. @@ -32,7 +33,24 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new FileSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['file_managed']['fields']['status']['not null'] = TRUE; + $schema['file_managed']['fields']['changed']['not null'] = TRUE; + $schema['file_managed']['fields']['uri']['not null'] = TRUE; + + // @todo There should be a 'binary' field type or setting. + $schema['file_managed']['fields']['uri']['binary'] = TRUE; + $schema['file_managed']['indexes'] += array( + 'file__status' => array('status'), + 'file__changed' => array('changed'), + ); + $schema['file_managed']['unique keys'] += array( + 'file__uri' => array('uri'), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/node/src/NodeSchemaHandler.php +++ /dev/null @@ -1,64 +0,0 @@ - array('langcode'), - ); - $schema['node_revision']['foreign keys'] += array( - 'node__revision_author' => array( - 'table' => 'users', - 'columns' => array('revision_uid' => 'uid'), - ), - ); - - $schema['node_field_data']['indexes'] += array( - 'node__changed' => array('changed'), - 'node__created' => array('created'), - 'node__default_langcode' => array('default_langcode'), - 'node__langcode' => array('langcode'), - 'node__frontpage' => array('promote', 'status', 'sticky', 'created'), - 'node__status_type' => array('status', 'type', 'nid'), - 'node__title_type' => array('title', array('type', 4)), - ); - - $schema['node_field_revision']['indexes'] += array( - 'node__default_langcode' => array('default_langcode'), - 'node__langcode' => array('langcode'), - ); - - return $schema; - } - -} diff -u b/core/modules/node/src/NodeStorage.php b/core/modules/node/src/NodeStorage.php --- b/core/modules/node/src/NodeStorage.php +++ b/core/modules/node/src/NodeStorage.php @@ -8,6 +8,7 @@ namespace Drupal\node; use Drupal\Core\Entity\ContentEntityDatabaseStorage; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Language\LanguageInterface; @@ -64,7 +65,45 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new NodeSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['node_field_data']['fields']['changed']['not null'] = TRUE; + $schema['node_field_data']['fields']['created']['not null'] = TRUE; + $schema['node_field_data']['fields']['default_langcode']['not null'] = TRUE; + $schema['node_field_data']['fields']['promote']['not null'] = TRUE; + $schema['node_field_data']['fields']['status']['not null'] = TRUE; + $schema['node_field_data']['fields']['sticky']['not null'] = TRUE; + $schema['node_field_data']['fields']['title']['not null'] = TRUE; + $schema['node_field_revision']['fields']['default_langcode']['not null'] = TRUE; + + // @todo Revisit index definitions in https://drupal.org/node/2015277. + $schema['node_revision']['indexes'] += array( + 'node__langcode' => array('langcode'), + ); + $schema['node_revision']['foreign keys'] += array( + 'node__revision_author' => array( + 'table' => 'users', + 'columns' => array('revision_uid' => 'uid'), + ), + ); + + $schema['node_field_data']['indexes'] += array( + 'node__changed' => array('changed'), + 'node__created' => array('created'), + 'node__default_langcode' => array('default_langcode'), + 'node__langcode' => array('langcode'), + 'node__frontpage' => array('promote', 'status', 'sticky', 'created'), + 'node__status_type' => array('status', 'type', 'nid'), + 'node__title_type' => array('title', array('type', 4)), + ); + + $schema['node_field_revision']['indexes'] += array( + 'node__default_langcode' => array('default_langcode'), + 'node__langcode' => array('langcode'), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/taxonomy/src/TermSchemaHandler.php +++ /dev/null @@ -1,119 +0,0 @@ - array('vid', 'weight', 'name'), - 'taxonomy_term__vid_name' => array('vid', 'name'), - 'taxonomy_term__name' => array('name'), - ); - } - - $schema['taxonomy_term_hierarchy'] = array( - 'description' => 'Stores the hierarchical relationship between terms.', - 'fields' => array( - 'tid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.', - ), - 'parent' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.", - ), - ), - 'indexes' => array( - 'parent' => array('parent'), - ), - 'foreign keys' => array( - 'taxonomy_term_data' => array( - 'table' => 'taxonomy_term_data', - 'columns' => array('tid' => 'tid'), - ), - ), - 'primary key' => array('tid', 'parent'), - ); - - $schema['taxonomy_index'] = array( - 'description' => 'Maintains denormalized information about node/term relationships.', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid this record tracks.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'tid' => array( - 'description' => 'The term ID.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'sticky' => array( - 'description' => 'Boolean indicating whether the node is sticky.', - 'type' => 'int', - 'not null' => FALSE, - 'default' => 0, - 'size' => 'tiny', - ), - 'created' => array( - 'description' => 'The Unix timestamp when the node was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default'=> 0, - ), - ), - 'primary key' => array('nid', 'tid'), - 'indexes' => array( - 'term_node' => array('tid', 'sticky', 'created'), - ), - 'foreign keys' => array( - 'tracked_node' => array( - 'table' => 'node', - 'columns' => array('nid' => 'nid'), - ), - 'term' => array( - 'table' => 'taxonomy_term_data', - 'columns' => array('tid' => 'tid'), - ), - ), - ); - - return $schema; - } - -} diff -u b/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php --- b/core/modules/taxonomy/src/TermStorage.php +++ b/core/modules/taxonomy/src/TermStorage.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Query\QueryInterface; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; /** * Defines a Controller class for taxonomy terms. @@ -159,7 +160,98 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new TermSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['taxonomy_term_field_data']['fields']['weight']['not null'] = TRUE; + $schema['taxonomy_term_field_data']['fields']['name']['not null'] = TRUE; + + unset($schema['taxonomy_term_field_data']['indexes']['taxonomy_term_field__vid__target_id']); + unset($schema['taxonomy_term_field_data']['indexes']['taxonomy_term_field__description__format']); + $schema['taxonomy_term_field_data']['indexes'] += array( + 'taxonomy_term__tree' => array('vid', 'weight', 'name'), + 'taxonomy_term__vid_name' => array('vid', 'name'), + 'taxonomy_term__name' => array('name'), + ); + + $schema['taxonomy_term_hierarchy'] = array( + 'description' => 'Stores the hierarchical relationship between terms.', + 'fields' => array( + 'tid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.', + ), + 'parent' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.", + ), + ), + 'indexes' => array( + 'parent' => array('parent'), + ), + 'foreign keys' => array( + 'taxonomy_term_data' => array( + 'table' => 'taxonomy_term_data', + 'columns' => array('tid' => 'tid'), + ), + ), + 'primary key' => array('tid', 'parent'), + ); + + $schema['taxonomy_index'] = array( + 'description' => 'Maintains denormalized information about node/term relationships.', + 'fields' => array( + 'nid' => array( + 'description' => 'The {node}.nid this record tracks.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'tid' => array( + 'description' => 'The term ID.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'sticky' => array( + 'description' => 'Boolean indicating whether the node is sticky.', + 'type' => 'int', + 'not null' => FALSE, + 'default' => 0, + 'size' => 'tiny', + ), + 'created' => array( + 'description' => 'The Unix timestamp when the node was created.', + 'type' => 'int', + 'not null' => TRUE, + 'default'=> 0, + ), + ), + 'primary key' => array('nid', 'tid'), + 'indexes' => array( + 'term_node' => array('tid', 'sticky', 'created'), + ), + 'foreign keys' => array( + 'tracked_node' => array( + 'table' => 'node', + 'columns' => array('nid' => 'nid'), + ), + 'term' => array( + 'table' => 'taxonomy_term_data', + 'columns' => array('tid' => 'tid'), + ), + ), + ); + return $schema; + }); } return $this->schemaHandler; } reverted: --- b/core/modules/user/src/UserSchemaHandler.php +++ /dev/null @@ -1,74 +0,0 @@ - array('access'), - 'user__created' => array('created'), - 'user__mail' => array('mail'), - ); - $schema['users_field_data']['unique keys'] += array( - 'user__name' => array('name', 'langcode'), - ); - - $schema['users_roles'] = array( - 'description' => 'Maps users to roles.', - 'fields' => array( - 'uid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Primary Key: {users}.uid for user.', - ), - 'rid' => array( - 'type' => 'varchar', - 'length' => 64, - 'not null' => TRUE, - 'description' => 'Primary Key: ID for the role.', - ), - ), - 'primary key' => array('uid', 'rid'), - 'indexes' => array( - 'rid' => array('rid'), - ), - 'foreign keys' => array( - 'user' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - ); - - return $schema; - } - -} diff -u b/core/modules/user/src/UserStorage.php b/core/modules/user/src/UserStorage.php --- b/core/modules/user/src/UserStorage.php +++ b/core/modules/user/src/UserStorage.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; use Drupal\Core\Password\PasswordInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -154,6 +155,9 @@ $this->resetCache(array($account->id())); } + /** + * {@inheritdoc} + */ public function updateLastAccessTimestamp(AccountInterface $account, $timestamp) { $this->database->update('users_field_data') ->fields(array( @@ -170,7 +174,55 @@ */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new UserSchemaHandler($this->entityManager, $this->entityType, $this, $this->database); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database, function ($schema) { + // The "users" table does not use serial identifiers. + $schema['users']['fields']['uid']['type'] = 'int'; + + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['users_field_data']['fields']['access']['not null'] = TRUE; + $schema['users_field_data']['fields']['created']['not null'] = TRUE; + $schema['users_field_data']['fields']['name']['not null'] = TRUE; + + $schema['users_field_data']['indexes'] += array( + 'user__access' => array('access'), + 'user__created' => array('created'), + 'user__mail' => array('mail'), + ); + $schema['users_field_data']['unique keys'] += array( + 'user__name' => array('name', 'langcode'), + ); + + $schema['users_roles'] = array( + 'description' => 'Maps users to roles.', + 'fields' => array( + 'uid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Primary Key: {users}.uid for user.', + ), + 'rid' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'description' => 'Primary Key: ID for the role.', + ), + ), + 'primary key' => array('uid', 'rid'), + 'indexes' => array( + 'rid' => array('rid'), + ), + 'foreign keys' => array( + 'user' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + ), + ); + return $schema; + }); } return $this->schemaHandler; } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -234,7 +234,7 @@ public function getSchema() { */ protected function schemaHandler() { if (!isset($this->schemaHandler)) { - $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this); + $this->schemaHandler = new ContentEntitySchemaHandler($this->entityManager, $this->entityType, $this, $this->database); } return $this->schemaHandler; }