- π¦πΊAustralia taggartj
This is still an issue in Drupal 10 please see
/** * Adds a prime key id so I can finish early today. */ function MYMODULE_update_8002() { // Add a prime key for views base. $spec = [ 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ]; $db = \Drupal::database(); $schema = $db->schema(); if ($schema->fieldExists('some_custom_table', 'id')) { $schema->dropField('some_custom_table', 'id'); } // THESE HERE Don't work as they should //$schema->addField('some_custom_table', 'id', $spec, ['id']); //$schema->addPrimaryKey('some_custom_table', ['id']); // Resulting to hackery. $table = 'some_custom_table'; $col = 'id'; $db->query('ALTER TABLE {' . $table . '} ADD {'. $col .'} INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY ({'. $col .'})'); }
- π¨π¦Canada Shane Birley
Unsure if bumping this one is the way to go but I have run into this issue during a Drupal 8 > 9.5.11 upgrade.
Running MariaDB 10.11.7.
Reviewing previous patches but they appear to already be in play.