function SchemaUniquePrefixedKeysIndexTestBase::testAddField
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::testAddField()
- 10 core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::testAddField()
Tests adding a new field with UNIQUE key.
Attributes
#[IgnoreDeprecations]
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php, line 69
Class
- SchemaUniquePrefixedKeysIndexTestBase
- Tests adding UNIQUE keys to tables.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testAddField() : void {
$this->expectUserDeprecationMessage('Specification of unique keys with column length is deprecated in drupal:12.1.0 and will throw a SchemaException from drupal:13.0.0. Specify full columns for an unique key, or use an index for columns with partial length. See https://www.drupal.org/node/3375071');
$field_spec = [
'type' => 'varchar',
'length' => 50,
];
$keys_spec = [
'unique keys' => [
'field' => [
[
'field',
10,
],
],
],
];
$this->connection
->schema()
->addField('test', 'field', $field_spec, $keys_spec);
$this->checkUniqueConstraintException('test', 'field');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.