Missing unique constraint on Jetstream team names (Laravel 9/Jetstream 2.x)
0 reputation · 17 Jul 2022, 06:22 UTC
When using Laravel Jetstream 2.x with Laravel 9, the default team migration creates a teams table that includes a name string column but does not add a unique database constraint. This means two different users can create teams with identical names, and concurrent requests may result in race conditions that allow duplicate entries to be saved.
The documentation does not clarify whether this omission is intentional or an oversight, nor does it provide a built‑in mechanism to enforce uniqueness. Developers therefore must decide how to handle potential duplicates and whether to add a custom unique index or implement application‑level checks.
- Is the lack of a unique index on the
namecolumn an intentional design choice in Jetstream 2.x, or is it an oversight that should be reported? - Does Jetstream expose any configuration or helper that can enforce unique team names without manually altering the migration?
- What is the recommended approach for preventing duplicate team names in high‑concurrency scenarios while maintaining Jetstream’s default structure?