-
Notifications
You must be signed in to change notification settings - Fork 299
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
Fix Grafana teams sync #1652
Fix Grafana teams sync #1652
Conversation
) | ||
|
||
team = models.ForeignKey( | ||
"user_management.Team", | ||
on_delete=models.SET_NULL, | ||
on_delete=NON_POLYMORPHIC_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.
main change of the PR
@@ -15,3 +16,23 @@ def get_random_readonly_database_key_if_present_otherwise_default() -> str: | |||
if hasattr(settings, "READONLY_DATABASES") and len(settings.READONLY_DATABASES) > 0: | |||
using_db = random.choice(list(settings.READONLY_DATABASES.keys())) | |||
return using_db | |||
|
|||
|
|||
def NON_POLYMORPHIC_SET_NULL(collector, field, sub_objs, using): |
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.
main change of the PR
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.
LGTM 👍
What this PR does
Sometimes plugin sync fails with the following exception:
How to reproduce:
This happens because the
OnCallSchedule
Django model is a polymorphic model and there's a known bug indjango-polymorphic
with deleting related objects when usingon_delete=SET_NULL
andon_delete=CASCADE
. This PR adds non-polymorphic versions ofSET_NULL
andCASCADE
to use in schedule FKs as per this comment.This also applies to two other schedule FKs:
organization
anduser_group
, which are not working properly as well.Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)