Skip to content

ref(crons): Set null for owner_user_id when a user is deleted #69034

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

Conversation

evanpurkhiser
Copy link
Member

No description provided.

@evanpurkhiser evanpurkhiser requested a review from a team as a code owner April 16, 2024 20:19
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 16, 2024
Copy link
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but I assume you need to generate a migration here

@@ -251,7 +251,7 @@ class Monitor(Model):
Type of monitor. Currently there are only CRON_JOB monitors.
"""

owner_user_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete="CASCADE")
owner_user_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete="SET_NULL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think maybe it's better to use HybridCloudForeignKeyCascadeBehavior.SET_NULL. Both are valid, but it's easier to see all the options for other people looking for examples

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but we don't do it anywhere else lol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥲

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me clean up

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/ref-crons-set-null-for-owner-user-id-when-a-user-is-deleted branch from 87c90fa to 283b24b Compare April 16, 2024 20:36
@evanpurkhiser evanpurkhiser requested a review from a team as a code owner April 16, 2024 20:36
@evanpurkhiser evanpurkhiser enabled auto-merge (squash) April 16, 2024 20:38
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0699_update_monitor_owner_team_id_cascsade.py ()

--
-- Alter field owner_user_id on monitor
--
-- (no-op)

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. When a user is deleted, any owner_user_id with a matching value will be nulled out eventually by tombstones.

@evanpurkhiser evanpurkhiser merged commit 09b4607 into master Apr 16, 2024
48 checks passed
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/ref-crons-set-null-for-owner-user-id-when-a-user-is-deleted branch April 16, 2024 21:27
@evanpurkhiser evanpurkhiser self-assigned this Apr 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants