Open
Description
- Postgres has the UUID type: https://www.postgresql.org/docs/current/datatype-uuid.html
- MySQL advices to store UUIDs as binary values because of index performance: https://dev.mysql.com/blog-archive/storing-uuid-values-in-mysql-tables/
- SQLite could use BLOB to store the binary representation
In case we need to convert from UUID to binary (MySQL and SQLite), the easiest way to do it would be in PHP:
- That way we don't have to worry about special inserts per database-dialect.
- Selecting should be done using the binary format of the UUID, so we'd have to convert it before building the select query
- The
CreateTableStatement
andAlterTableStatement
should simply have auuid()
method that creates the field with a unique index - We might have an option to store the "human readable" version in the database as well
An example of how this was done with a Laravel package (before Laravel had support for it): https://github.com/spatie/laravel-binary-uuid/tree/master
Having thought it through, I think we're in the clear about breaking changes, and can move this to post-1.0
Activity
iamdadmin commentedon May 17, 2025
Just adding, it would be good if the UUID supported was specifically UUIDv7 so it's sortable https://uuid7.com - coming from Laravel I've been using ULID for the advantages, but UUIDv7 makes ULID unnecessary and obviously there's wider support then.
1 remaining item