feat: add UUIDv7Mixin (#140)

This commit is contained in:
d3vyce
2026-03-14 20:41:46 +01:00
committed by GitHub
parent 19c013bdec
commit aedcbf4e04
4 changed files with 92 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ from sqlalchemy.orm import Mapped, mapped_column
__all__ = [
"UUIDMixin",
"UUIDv7Mixin",
"CreatedAtMixin",
"UpdatedAtMixin",
"TimestampMixin",
@@ -24,6 +25,16 @@ class UUIDMixin:
)
class UUIDv7Mixin:
"""Mixin that adds a UUIDv7 primary key auto-generated by the database."""
id: Mapped[uuid.UUID] = mapped_column(
Uuid,
primary_key=True,
server_default=text("uuidv7()"),
)
class CreatedAtMixin:
"""Mixin that adds a ``created_at`` timestamp column."""