/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // Marking the respective fields as NOT NULL makes the indexes more // performant. $schema['block_content']['fields']['info']['not null'] = TRUE; $schema['block_content']['unique keys'] += array('block_content__info' => array('info')); return $schema; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // 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; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // 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; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // 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; }
/** * Tests ContentEntityDatabaseStorage::getSchema(). * * @covers ::__construct() * @covers ::getSchema() * @covers ::schemaHandler() * @covers ::getTableMapping() */ public function testGetSchema() { $columns = array('value' => array('type' => 'int')); $this->fieldDefinitions['id'] = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $this->fieldDefinitions['id']->expects($this->once())->method('getColumns')->will($this->returnValue($columns)); $this->fieldDefinitions['id']->expects($this->once())->method('getSchema')->will($this->returnValue(array('columns' => $columns))); $this->entityType->expects($this->once())->method('getKeys')->will($this->returnValue(array('id' => 'id'))); $this->entityType->expects($this->any())->method('getKey')->will($this->returnValueMap(array(array('id', 'id'), array('uuid', NULL), array('bundle', NULL), array('id' => 'id'), array('id' => 'id')))); $this->entityManager->expects($this->once())->method('getFieldStorageDefinitions')->with($this->entityType->id())->will($this->returnValue($this->fieldDefinitions)); $this->setUpEntityStorage(); $expected = array('entity_test' => array('description' => 'The base table for entity_test entities.', 'fields' => array('id' => array('type' => 'serial', 'description' => NULL, 'not null' => TRUE)), 'primary key' => array('id'), 'unique keys' => array(), 'indexes' => array(), 'foreign keys' => array())); $this->assertEquals($expected, $this->entityStorage->getSchema()); // Test that repeated calls do not result in repeatedly instantiating // ContentEntitySchemaHandler as getFieldStorageDefinitions() is only // expected to be called once. $this->assertEquals($expected, $this->entityStorage->getSchema()); }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // 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; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // Marking the respective fields as NOT NULL makes the indexes more // performant. $schema['taxonomy_term_data']['fields']['weight']['not null'] = TRUE; $schema['taxonomy_term_data']['fields']['name']['not null'] = TRUE; unset($schema['taxonomy_term_data']['indexes']['field__vid']); unset($schema['taxonomy_term_data']['indexes']['field__description__format']); $schema['taxonomy_term_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; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // Marking the respective fields as NOT NULL makes the indexes more // performant. $schema['users']['fields']['access']['not null'] = TRUE; $schema['users']['fields']['created']['not null'] = TRUE; $schema['users']['fields']['name']['not null'] = TRUE; // The "users" table does not use serial identifiers. $schema['users']['fields']['uid']['type'] = 'int'; $schema['users']['indexes'] += array('user__access' => array('access'), 'user__created' => array('created'), 'user__mail' => array('mail')); $schema['users']['unique keys'] += array('user__name' => array('name')); $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; }
/** * {@inheritdoc} */ public function getSchema() { $schema = parent::getSchema(); // 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; }