From 2321e9cd7054627d877d98e8cc7b7f06199549f9 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Tue, 20 Apr 2021 22:41:39 +0800 Subject: [PATCH] Add primary method on migration generator for UUID --- src/Generators/MigrationGenerator.php | 2 +- tests/CommandOptions/UuidOptionsTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generators/MigrationGenerator.php b/src/Generators/MigrationGenerator.php index f5772f8..68c7cf8 100644 --- a/src/Generators/MigrationGenerator.php +++ b/src/Generators/MigrationGenerator.php @@ -31,7 +31,7 @@ public function getContent(string $stubName) $content = $this->replaceStubString($this->getStubFileContent($stubName)); if ($this->command->option('uuid')) { - $content = str_replace("\$table->bigIncrements('id')", "\$table->uuid('id')", $content); + $content = str_replace("\$table->bigIncrements('id')", "\$table->uuid('id')->primary()", $content); } return $content; diff --git a/tests/CommandOptions/UuidOptionsTest.php b/tests/CommandOptions/UuidOptionsTest.php index e45ad82..cded887 100644 --- a/tests/CommandOptions/UuidOptionsTest.php +++ b/tests/CommandOptions/UuidOptionsTest.php @@ -29,7 +29,7 @@ class Create{$this->plural_model_name}Table extends Migration public function up() { Schema::create('{$this->table_name}', function (Blueprint \$table) { - \$table->uuid('id'); + \$table->uuid('id')->primary(); \$table->string('title', 60); \$table->string('description')->nullable(); \$table->foreignId('creator_id')->constrained('users')->onDelete('restrict');