diff --git a/serial.install b/serial.install index 97deae2e6f62d70c020273d94363bb7d736ef7ff..87228656e1638b7fdc4b0517f35f30282ac97d88 100644 --- a/serial.install +++ b/serial.install @@ -24,3 +24,20 @@ function serial_schema() { } return $schema; } + +/** + * Drop uniqid field from the serial storage. + */ +function serial_update_8001() { + /** @var \Drupal\serial\SerialStorageInterface $serialStorage */ + $serialStorage = \Drupal::getContainer()->get('serial.sql_storage'); + + foreach ($serialStorage->getAllFields() as $entityTypeId => $entry) { + foreach ($entry as $fieldKey => $fieldInstance) { + foreach ($fieldInstance['bundles'] as $bundle) { + $table = $serialStorage->createStorageName($entityTypeId, $bundle, $fieldKey); + \Drupal::database()->schema()->dropField($table, 'uniqid'); + } + } + } +} diff --git a/src/SerialSQLStorage.php b/src/SerialSQLStorage.php index f755abe530909371359528748125c3df1b791610..f9a41f5393854ae89bb575e9811f84c4e458c797 100644 --- a/src/SerialSQLStorage.php +++ b/src/SerialSQLStorage.php @@ -90,9 +90,8 @@ class SerialSQLStorage implements ContainerInjectionInterface, SerialStorageInte try { // Insert a temporary record to get a new unique serial value. - $uniqid = uniqid('', TRUE); $sid = $connection->insert($storageName) - ->fields(['uniqid' => $uniqid]) + ->fields(['sid' => NULL]) ->execute(); // If there's a reason why it's come back undefined, reset it. @@ -143,19 +142,8 @@ class SerialSQLStorage implements ContainerInjectionInterface, SerialStorageInte 'unsigned' => TRUE, 'description' => 'The atomic serial field.', ], - 'uniqid' => [ - 'type' => 'varchar', - 'length' => 23, - 'default' => '', - 'not null' => TRUE, - // @todo review UUID instead - 'description' => 'Unique temporary allocation Id.', - ], ], 'primary key' => ['sid'], - 'unique keys' => [ - 'uniqid' => ['uniqid'], - ], ]; return $schema; }