Skip to content

feat(database): support uuids as primary columns#1807

Merged
innocenzi merged 4 commits into3.xfrom
feat/uuid
Dec 14, 2025
Merged

feat(database): support uuids as primary columns#1807
innocenzi merged 4 commits into3.xfrom
feat/uuid

Conversation

@innocenzi
Copy link
Member

Closes #619

This pull request adds support for generating UUID v7 primary keys during insertion. Note that since IsDatabaseModel provides a id property, which cannot be extended to receive the #[Uuid] attribute, this feature is technically not compatible with IsDatabaseModel.

final class User
{
    #[Uuid]
    public PrimaryKey $id;

    public function __construct(
        public string $name,
    ) {}
}

@innocenzi innocenzi marked this pull request as draft December 11, 2025 21:42
@innocenzi innocenzi marked this pull request as ready for review December 14, 2025 00:45
@innocenzi innocenzi merged commit 4456541 into 3.x Dec 14, 2025
74 checks passed
@innocenzi innocenzi deleted the feat/uuid branch December 14, 2025 01:19
public function compile(DatabaseDialect $dialect): string
{
return match ($dialect) {
DatabaseDialect::MYSQL => sprintf('`%s` VARCHAR(36) PRIMARY KEY', $this->name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I read this while reading the Tempest 3.0 announcement, thanks for your work on this guys)

VARCHAR(36) is not the optimal datatype. I do not know what is feasible with tempest.

Also, I do not know how MariaDB is handled, but they have an UUID type: https://mariadb.com/docs/server/reference/data-types/string-data-types/uuid-data-type

(I do not know about sqlite)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I made an issue for it: #1966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants