function SchemaUniquePrefixedKeysIndexTestBase::testChangeField
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::testChangeField()
- 10 core/tests/Drupal/KernelTests/Core/Database/SchemaUniquePrefixedKeysIndexTestBase.php \Drupal\KernelTests\Core\Database\SchemaUniquePrefixedKeysIndexTestBase::testChangeField()
Tests changing a field to add a UNIQUE key.
Attributes
#[IgnoreDeprecations]
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SchemaUniquePrefixedKeysIndexTestBase.php, line 90
Class
- SchemaUniquePrefixedKeysIndexTestBase
- Tests adding UNIQUE keys to tables.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testChangeField() : 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 = [
'description' => "The person's job",
'type' => 'varchar_ascii',
'length' => 50,
'not null' => TRUE,
'default' => '',
];
$keys_spec = [
'unique keys' => [
'job' => [
[
'job',
10,
],
],
],
];
$this->connection
->schema()
->changeField('test_people', 'job', 'job', $field_spec, $keys_spec);
$this->checkUniqueConstraintException('test_people', 'job');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.