Skip to content

Commit 36a7bb0

Browse files
committed
Converted uuid4 to uuid7
1 parent 339bf58 commit 36a7bb0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/app/core/db/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class UUIDMixin:
1111
uuid: Mapped[uuid_pkg.UUID] = mapped_column(
12-
UUID, primary_key=True, default=uuid7(), server_default=text("gen_random_uuid()")
12+
UUID(as_uuid=True), primary_key=True, default=uuid7, server_default=text("gen_random_uuid()")
1313
)
1414

1515

src/app/models/post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Post(Base):
1515
created_by_user_id: Mapped[int] = mapped_column(ForeignKey("user.id"), index=True)
1616
title: Mapped[str] = mapped_column(String(30))
1717
text: Mapped[str] = mapped_column(String(63206))
18-
uuid: Mapped[uuid_pkg.UUID] = mapped_column(default_factory=uuid7(), primary_key=True, unique=True)
18+
uuid: Mapped[uuid_pkg.UUID] = mapped_column(default_factory=uuid7, primary_key=True, unique=True)
1919
media_url: Mapped[str | None] = mapped_column(String, default=None)
2020

2121
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default_factory=lambda: datetime.now(UTC))

src/scripts/create_first_superuser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def create_first_user(session: AsyncSession) -> None:
3737
Column("email", String(50), nullable=False, unique=True, index=True),
3838
Column("hashed_password", String, nullable=False),
3939
Column("profile_image_url", String, default="https://profileimageurl.com"),
40-
Column("uuid", UUID(as_uuid=True), primary_key=True, default=uuid7(), unique=True),
40+
Column("uuid", UUID(as_uuid=True), primary_key=True, default=uuid7, unique=True),
4141
Column("created_at", DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False),
4242
Column("updated_at", DateTime),
4343
Column("deleted_at", DateTime),

tests/helpers/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def create_user(db: Session, is_super_user: bool = False) -> models.User:
1414
email=fake.email(),
1515
hashed_password=get_password_hash(fake.password()),
1616
profile_image_url=fake.image_url(),
17-
uuid=uuid7(),
17+
uuid=uuid7,
1818
is_superuser=is_super_user,
1919
)
2020

0 commit comments

Comments
 (0)