From 32b99cec7c566d95e95fdf2d12b9f6448dadc4a0 Mon Sep 17 00:00:00 2001
From: Benji Fisher <benji@FisherFam.org>
Date: Thu, 29 Feb 2024 22:38:17 -0500
Subject: [PATCH 1/2] Issue #3152940, Comment #2

---
 serial.install           | 18 ++++++++++++++++++
 src/SerialSQLStorage.php | 14 +-------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/serial.install b/serial.install
index 97deae2..b47f1ca 100644
--- a/serial.install
+++ b/serial.install
@@ -24,3 +24,21 @@ 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 f755abe..f9a41f5 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;
   }
-- 
GitLab


From 93d3a034757727918303545e4d5c5dff0897449e Mon Sep 17 00:00:00 2001
From: Benji Fisher <benji@FisherFam.org>
Date: Thu, 29 Feb 2024 22:38:55 -0500
Subject: [PATCH 2/2] Remove empty line at end of file

---
 serial.install | 1 -
 1 file changed, 1 deletion(-)

diff --git a/serial.install b/serial.install
index b47f1ca..8722865 100644
--- a/serial.install
+++ b/serial.install
@@ -41,4 +41,3 @@ function serial_update_8001() {
     }
   }
 }
-
-- 
GitLab