-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ref(crons): Set null for owner_user_id when a user is deleted #69034
Conversation
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.
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") |
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.
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
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.
Yeah but we don't do it anywhere else lol
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.
🥲
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.
let me clean up
87c90fa
to
283b24b
Compare
This PR has a migration; here is the generated SQL for --
-- Alter field owner_user_id on monitor
--
-- (no-op) |
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.
Looks good to me. When a user is deleted, any owner_user_id with a matching value will be nulled out eventually by tombstones.
No description provided.