-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read Token.user_id
instead of Token.userid
#8521
Conversation
@@ -55,6 +56,7 @@ class Token(Base, mixins.Timestamps): | |||
index=True, | |||
nullable=True, | |||
) | |||
user: Mapped["User"] = sqlalchemy.orm.relationship(back_populates="tokens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a relationship so you can do token.user
to get a token's user (works via the token.user_id
foreign key relationship)
@@ -42,7 +42,7 @@ def create(self, userid): | |||
""" | |||
user = self.user_svc.fetch(userid) | |||
token = models.Token( | |||
userid=user.userid, user_id=user.id, value=self._generate_token() | |||
user=user, userid=user.userid, value=self._generate_token() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing both user
(which writes user_id
) and the old userid
(this will be removed soon).
5970e3d
to
019985e
Compare
Remove all **reads** of the `Token.userid` column, replacing them with reads of the new `Token.user_id` column instead. This prepares the way for actually removing the `Token.userid` column. For now the code does still need to **write** `Token.userid` because it's not nullable.
019985e
to
812d23a
Compare
Remove all reads of the
Token.userid
column, replacing them with reads of the newToken.user_id
column instead.This prepares the way for actually removing the
Token.userid
column.For now the code does still need to write
Token.userid
because it's not nullable.