michaeldyrynda / laravel-efficient-uuid

MIT License
304 stars 42 forks source link

Default value for uuid column #50

Closed maxcelos closed 2 years ago

maxcelos commented 2 years ago

Looking for a way to make easy to insert data using a graphic interface like TablePlus or Workbench.

I'm testing setup the default value for uuid column to auto generate the binary uuid so we can just leave it black like the id:

$table->efficientUuid('uuid')->index()->default(\Illuminate\Support\Facades\DB::raw('(uuid_to_bin(uuid()))'));

Does anyone uses it or see any problem?

Screen Shot 2021-12-29 at 08 07 01

michaeldyrynda commented 2 years ago

I’ve not done this myself (usually leave it without a default and let dyrynda/laravel-model-uuid handle setting the value), but so long as the binary implementation matches the one in ramsey/uuid and you configure matching UUID versions, I don’t see a theoretical issue with this working.