I am making UUIDs like this:
Uuid::uuid4();
and save in a database as track id
.
Is it possible to create a duplicate UUID?
If you are not using a unique
column, then you can look up the UUID from the database and save it in another record. You cannot feasibly generate a duplicate UUID using Uuid:uuid4()
without astronomical odds, however.
If you intend to use the UUID as a unique identifier, best practice would be to also add a unique
constraint on your database column.