Active
Project:
Drupal core
Version:
main
Component:
mysql db driver
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2025 at 22:20 UTC
Updated:
14 Jan 2025 at 12:47 UTC
Jump to comment: Most recent
Faced in #3159210-59: Support route aliasing (Symfony 5.4) and allow deprecating the route name
The method implementation in mysql schema require to pass fields within spec for indexes but pgsql/sqlite require only keys definition in $keys_new
$spec = [
'fields' => [
'alias' => [
'description' => 'The alias of the route, if applicable.',
'type' => 'varchar_ascii',
'length' => 255,
],
],
];
$schema->addField('router', 'alias', $spec['fields']['alias']);
$schema->addIndex('router', 'alias', ['alias'], $spec);
Comments
Comment #2
andypostthe commit which breaks https://git.drupalcode.org/project/drupal/-/commit/eea37702137e1dce6036f...
it means mysql require to pass "fields" but other drivers are not (as doc block said)
@daffie please check if it works for mongodb
Comment #3
andypostIt was added in #1314214: MySQL driver does not support full UTF-8 (emojis, asian symbols, mathematical symbols)
The
mysql/Schema::getNormalizedIndexes()requirefieldsto be passedComment #4
daffie commentedThe
fieldskey needs to be set inmysql/Schema::getNormalizedIndexes(), because we are want the resulting index name to be less than 191 characters. When we use utf8mb4 the resulting index name will be below 756 bytes. That is the maximum name length for an index in InnoDB when the row format is REDUNDANT or COMPACT. See: https://dev.mysql.com/doc/refman/8.4/en/innodb-limits.html.If it is up to me we would not be doing index changes in the method
Schema::addField(). For the better and more stable solution would be the add a field first and then add an index in a seperate call withSchema::AddIndex(). That would be the better solution for all databases, including MongoDB.Comment #5
andypostThen at least doc-block needs rewording to point out that fields are required
from
\Drupal\Core\Database\Schema::addField()