Conversation
|
The codebase uses UUID v7 (uuid7), not UUID v4. Python's built-in uuid module only provides uuid1, uuid3, uuid4, and uuid5 — it does not support UUID v7. UUID v7 (RFC 9562) is specifically chosen here because it's time-ordered, which matters for database performance. Random UUID v4 values scatter inserts across B-tree indexes, causing page splits and bloat in PostgreSQL. UUID v7 embeds a timestamp in the most significant bits, so values are generated in chronological rder and append to the end of the index — similar to auto-incrementing integers but without sacrificing global uniqueness. The uuid6 package is a small, focused library that fills this gap in the stdlib. It's not a redundant wrapper around uuid it provides functionality that doesn't exist there yet. |
This PR addresses the "UUID usage" part of issue #248 by removing the direct dependency on external
uuid/uuid6packages and relying on Python's built-inuuidmodule instead.Changes:
uuidanduuid6from project dependencies inpyproject.toml.uuid7usage withuuid.uuid4()in:src/scripts/create_first_superuser.pysrc/app/models/user.pysrc/app/models/post.pysrc/app/core/schemas.pysrc/app/core/db/models.pyuuid.uuid4()intests/conftest.py.Tests:
uv run pytestuv run ruff check srcuv run mypy srcThis is a follow-up to issue #248.