Skip to content
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

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Conversation

seanh
Copy link
Contributor

@seanh seanh commented Feb 14, 2024

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.

@seanh seanh requested a review from marcospri February 14, 2024 14:22
@@ -55,6 +56,7 @@ class Token(Base, mixins.Timestamps):
index=True,
nullable=True,
)
user: Mapped["User"] = sqlalchemy.orm.relationship(back_populates="tokens")
Copy link
Contributor Author

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()
Copy link
Contributor Author

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).

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.
@seanh seanh merged commit bce2f7b into main Feb 15, 2024
9 checks passed
@seanh seanh deleted the dont-use-Token.userid branch February 15, 2024 10:02
@seanh seanh mentioned this pull request Feb 15, 2024
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants