From 7e68c485f27f87228cd5fc7bb9168cad2e25e3e6 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Sun, 21 Jan 2024 22:14:36 +0100 Subject: [PATCH] set primary key when keyType is string (#102) --- src/Sushi.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Sushi.php b/src/Sushi.php index 6c7fc95..fb3abcb 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -159,6 +159,10 @@ public function createTable(string $tableName, $firstRow) $type = $schema[$column] ?? $type; $table->{$type}($column)->nullable(); + + if ($column === $this->primaryKey) { + $table->primary($this->primaryKey); + } } if ($this->usesTimestamps() && (! in_array('updated_at', array_keys($firstRow)) || ! in_array('created_at', array_keys($firstRow)))) {