diff --git a/core/modules/block/block.install b/core/modules/block/block.install index ec72d062edf6..3c1755f7614e 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -252,6 +252,34 @@ function block_update_8008() { 'entity_types' => array('custom_block'), 'module' => 'text', 'cardinality' => 1, + 'schema' => array( + 'columns' => array( + 'value' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + 'summary' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + 'format' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + 'indexes' => array( + 'format' => array('format'), + ), + 'foreign keys' => array( + 'format' => array( + 'table' => 'filter_format', + 'columns' => array('format' => 'format'), + ), + ), + ), ); _update_8003_field_create_field($body_field); diff --git a/core/modules/field/field.install b/core/modules/field/field.install index b4251699eff9..c46346a097b6 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -15,7 +15,12 @@ use Drupal\field\Plugin\Core\Entity\Field; * they get executed after field_update_8003(). * * @param array $field_config - * An array of field properties. + * An array of field properties. Required properties are: + * - 'id': The field id (machine name). + * - 'type': The field type. + * - 'module': The name of the module providing the field type. + * - 'schema': The field schema, in the same format as + * Drupal\field\Plugin\Type\FieldType\ConfigFieldInterface::schema(). * * @ingroup update_api */ diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 8f3a995873c8..70c223606f3f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -153,6 +153,24 @@ class CrudTest extends FieldUnitTestBase { } } + /** + * Tests that an explicit schema can be provided on creation of a field. + * + * This behavior is needed to allow field creation within updates, since + * plugin classes (and thus the field type schema) cannot be accessed. + */ + function testCreateFieldWithExplicitSchema() { + $field_definition = array( + 'field_name' => 'field_2', + 'type' => 'test_field', + 'schema' => array( + 'dummy' => 'foobar' + ), + ); + $field = entity_create('field_entity', $field_definition); + $this->assertEqual($field->getSchema(), $field_definition['schema']); + } + /** * Test failure to create a field. */ diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 871c18d499a1..62eb4a93c1a0 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -665,6 +665,47 @@ function user_update_8011() { 'uri_scheme' => 'public', 'default_image' => FALSE, ), + 'schema' => array( + 'columns' => array( + 'target_id' => array( + 'description' => 'The ID of the target entity.', + 'type' => 'int', + 'not null' => TRUE, + 'unsigned' => TRUE, + ), + 'alt' => array( + 'description' => "Alternative image text, for the image's 'alt' attribute.", + 'type' => 'varchar', + 'length' => 512, + 'not null' => FALSE, + ), + 'title' => array( + 'description' => "Image title text, for the image's 'title' attribute.", + 'type' => 'varchar', + 'length' => 1024, + 'not null' => FALSE, + ), + 'width' => array( + 'description' => 'The width of the image in pixels.', + 'type' => 'int', + 'unsigned' => TRUE, + ), + 'height' => array( + 'description' => 'The height of the image in pixels.', + 'type' => 'int', + 'unsigned' => TRUE, + ), + ), + 'indexes' => array( + 'target_id' => array('target_id'), + ), + 'foreign keys' => array( + 'target_id' => array( + 'table' => 'file_managed', + 'columns' => array('target_id' => 'fid'), + ), + ), + ), ); _update_8003_field_create_field($field);