Created
October 7, 2022 08:45
-
-
Save ibayazit/dabcfd720e7b6e1f3542c7240d35312b to your computer and use it in GitHub Desktop.
Laravel uuid migration. pros and cons : With this way you can create UUID easily but the created user model doesn't return UUID or i couldn't find a way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
use Illuminate\Database\Query\Expression; | |
... | |
return new class extends Migration | |
{ | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create('users', function (Blueprint $table) { | |
$table->uuid('id')->primary()->unique()->default(new Expression('(UUID())')); | |
... | |
}); | |
} | |
... | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment