Skip to content

Commit

Permalink
Clear the associated_product_relation_status FK values
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed May 8, 2024
1 parent 85a50ca commit 87904c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
7 changes: 6 additions & 1 deletion dje/management/commands/flushdataset.py
Expand Up @@ -37,6 +37,7 @@ def add_arguments(self, parser):

def handle(self, *args, **options):
super().handle(*args, **options)
dataspace = self.dataspace

models = ALL_MODELS[:] # Making a copy to not impact the original list
models += WORKFLOW_MODELS
Expand All @@ -52,7 +53,11 @@ def handle(self, *args, **options):
Webhook,
])

dataspace = self.dataspace
# Clear the associated_product_relation_status FK values so the
# ProductRelationStatus model can be flushed before the UsagePolicy model.
usage_policies = UsagePolicy.objects.filter(dataspace=dataspace)
usage_policies.update(associated_product_relation_status=None)

for model_class in models:
qs = get_unsecured_manager(model_class).filter(dataspace=dataspace)
if options['verbosity'] > 1:
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion policy/models.py
Expand Up @@ -86,7 +86,7 @@ class Compliance(models.TextChoices):
to="product_portfolio.ProductRelationStatus",
null=True,
blank=True,
on_delete=models.SET_NULL,
on_delete=models.PROTECT,
help_text=_(
"An associated product relation status enables you to specify the product "
"relation status to use automatically when a component or package with an "
Expand Down

0 comments on commit 87904c3

Please sign in to comment.