Repository navigation
feat: UUIDv7 primary keys (Python 3.14 uuid7) - #12
Merged
Merged
Conversation
User.id is a uuid.UUID generated by uuid.uuid7() (Python 3.14, RFC 9562) instead of an auto-increment integer. An id no longer tells anyone who sees one how many accounts exist or in what order they were created, and version 7 is time-ordered, so the primary-key index still appends at the end rather than scattering as uuid4 would. The token subject was already str(user.id); get_current_user now parses it as a UUID and keeps the fixed 401 for anything else. Responses carry the id as a UUID string. Breaking for an existing database: the users.id column type changes and create_all never alters a column; migrate before upgrading a deployment with data. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
First of three PRs that use what Python 3.14 and the updated libraries make possible. This one adopts the single 3.14 feature with product impact on this code base:
uuid.uuid7()primary keys.Why
str(user.id), so the authentication model (id in the token, user loaded on every request, deletion effective at once) is unchanged in shape; only the type of the id moves.What changes
User.id: uuid.UUID = Field(default_factory=uuid.uuid7, primary_key=True); the column compiles to PostgreSQLUUID.UserResponseSchema.idis a UUID, serialised as a string.get_current_userparses the subject withuuid.UUID(...); anything else keeps the fixed401 Could not validate credentials.get_user_by_idand the service'sexclude_user_idtake a UUID.str(test_user.id); a new test registers two users and checks both ids are version 7, distinct, and that the later one sorts after the earlier.Breaking for an existing database
The
users.idcolumn type changes from integer to UUID.create_allcreates missing tables and never alters a column, so a deployment with data must migrate first. The starter has no deployment; the changelog says this plainly.Not changed
The other 3.14 features were evaluated and do not apply here (template strings, deferred annotations, multiple interpreters, free-threading, zstd); the plan and the next PRs record that so the question is not reopened.
Verified
black --check,flake8,mypypass; 34 database-free tests pass; 75 collect.UUIDfor PostgreSQL, a newUser()gets a version-7 id, the response schema serialises it as a string, and a token subject round-trips to the same UUID.testjob.🤖 Generated with Claude Code