DEV Community

Cover image for Implement UUID primary key in Laravel, and its benefits

Implement UUID primary key in Laravel, and its benefits

Adnan Babakan (he/him) on July 13, 2023

Hey, DEV.to community! It's been a long time since I last wrote here. During the time that I've been absent, I've been working on some large-scal...
Collapse
 
rbroberts profile image
Roland Roberts

You've probably got a session table, too. Which means you'll have one more migration to modify, similar to the others

$table->foreignUuid('user_id')->nullable()->index();

Collapse
 
adnanbabakan profile image
Adnan Babakan (he/him)

Thanks for the comment. Since I use Laravel as an API-only back-end I use Sanctum and not sessions. But what you said is essential for full-stack Laravel apps.

Collapse
 
jovialcore profile image
Chidiebere Chukwudi
Collapse
 
xmsi profile image
Muhammadumar

Awesome

Collapse
 
xmsi profile image
Muhammadumar

Fantastic!