Skip to content

Commit

Permalink
Consolidate migrations #569
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed May 8, 2023
1 parent a79cd7e commit de7f6a1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 83 deletions.
34 changes: 34 additions & 0 deletions scanpipe/migrations/0030_scancode_toolkit_v32_model_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,38 @@ class Migration(migrations.Migration):
name="scanpipe_di_other_l_1f1616_idx",
),
),

# CodebaseResource
migrations.RenameField(
model_name="codebaseresource",
old_name="license_expressions",
new_name="detected_license_expression",
),
migrations.AlterField(
model_name="codebaseresource",
name="detected_license_expression",
field=models.TextField(blank=True, help_text="TODO"),
),
migrations.RenameField(
model_name="codebaseresource",
old_name="licenses",
new_name="license_detections",
),
migrations.AddField(
model_name="codebaseresource",
name="detected_license_expression_spdx",
field=models.TextField(blank=True, help_text="TODO"),
),
migrations.AddField(
model_name="codebaseresource",
name="license_clues",
field=models.JSONField(
blank=True, default=list, help_text="List of license clues."
),
),
migrations.AddField(
model_name="codebaseresource",
name="percentage_of_license_text",
field=models.FloatField(blank=True, help_text="TODO", null=True),
),
]
9 changes: 6 additions & 3 deletions scanpipe/migrations/0031_scancode_toolkit_v32_data_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from django.db.models import Q


def compute_declared_license_expression_spdx(apps, schema_editor):
def compute_package_declared_license_expression_spdx(apps, schema_editor):
"""
Compute `declared_license_expression_spdx`, when missing,
Compute DiscoveredPackage `declared_license_expression_spdx`, when missing,
from `declared_license_expression`, when available.
"""
from licensedcode.cache import build_spdx_license_expression
Expand All @@ -28,5 +28,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunPython(compute_declared_license_expression_spdx),
migrations.RunPython(
compute_package_declared_license_expression_spdx,
reverse_code=migrations.RunPython.noop,
),
]

This file was deleted.

This file was deleted.

7 changes: 3 additions & 4 deletions scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,17 +1438,16 @@ def has_value(self, field_name):
return self.filter(~Q((f"{field_name}__in", EMPTY_VALUES)))


# TODO: Add in UI, API, ...
class ScanFieldsModelMixin(models.Model):
"""Fields returned by the ScanCode-toolkit scans."""

detected_license_expression = models.TextField(
blank=True,
help_text=_(""),
help_text=_("TODO"),
)
detected_license_expression_spdx = models.TextField(
blank=True,
help_text=_(""),
help_text=_("TODO"),
)
license_detections = models.JSONField(
blank=True,
Expand All @@ -1463,7 +1462,7 @@ class ScanFieldsModelMixin(models.Model):
percentage_of_license_text = models.FloatField(
blank=True,
null=True,
help_text=_(""),
help_text=_("TODO"),
)
copyrights = models.JSONField(
blank=True,
Expand Down

0 comments on commit de7f6a1

Please sign in to comment.