From 660e0c79e11425ea805e2bffe5e5b6cc95c1f694 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 16 May 2023 17:19:28 -0700 Subject: [PATCH] Update package_set and package_content #95 * package_set is now a UUIDField * package_content is now an IntegerField Signed-off-by: Jono Yang --- ...age_package_content_package_package_set.py | 20 +++++++++-------- .../0065_set_package_content_field.py | 2 +- packagedb/models.py | 22 +++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packagedb/migrations/0064_package_package_content_package_package_set.py b/packagedb/migrations/0064_package_package_content_package_package_set.py index f59476db..9950cdec 100644 --- a/packagedb/migrations/0064_package_package_content_package_package_set.py +++ b/packagedb/migrations/0064_package_package_content_package_package_set.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.2 on 2023-05-16 00:48 +# Generated by Django 4.1.2 on 2023-05-17 00:05 from django.db import migrations, models @@ -12,22 +12,24 @@ class Migration(migrations.Migration): migrations.AddField( model_name="package", name="package_content", - field=models.CharField( + field=models.IntegerField( choices=[ - ("source", "Source"), - ("binary", "Binary"), - ("doc", "Doc"), - ("test", "Test"), + (1, "Curation"), + (2, "Patch"), + (3, "Source Repo"), + (4, "Source Archive"), + (5, "Binary"), + (6, "Test"), + (7, "Doc"), ], - help_text="Content of this Package as one of: source, binary, doc, test", - max_length=6, + help_text="Content of this Package as one of: Curation, Patch, Source Repo, Source Archive, Binary, Test, Doc", null=True, ), ), migrations.AddField( model_name="package", name="package_set", - field=models.TextField( + field=models.UUIDField( blank=True, help_text="A UUID used to identify a group of related Packages", null=True, diff --git a/packagedb/migrations/0065_set_package_content_field.py b/packagedb/migrations/0065_set_package_content_field.py index 333b3bd5..2ff32377 100644 --- a/packagedb/migrations/0065_set_package_content_field.py +++ b/packagedb/migrations/0065_set_package_content_field.py @@ -22,7 +22,7 @@ def set_package_content_field(apps, schema_editor): ) updated = [] if 'source' in package.qualifiers: - package.package_content = Package.PackageContentType.SOURCE + package.package_content = Package.PackageContentType.SOURCE_ARCHIVE updated.append(package) if updated: Package.objects.bulk_update( diff --git a/packagedb/models.py b/packagedb/models.py index 213a8634..d6e95325 100644 --- a/packagedb/models.py +++ b/packagedb/models.py @@ -477,26 +477,30 @@ class Package( blank=True, help_text='Indexing errors messages. When present this means the indexing has failed.', ) - package_set = models.TextField( + package_set = models.UUIDField( null=True, blank=True, help_text='A UUID used to identify a group of related Packages' ) - class PackageContentType(models.TextChoices): + class PackageContentType(models.IntegerChoices): """List of Package content types.""" - SOURCE = 'source' - BINARY = 'binary' - DOC = 'doc' - TEST = 'test' + # TODO: curation is a special case, based on how the curation identity + # fields matches with the current package + CURATION = 1 + PATCH = 2 + SOURCE_REPO = 3 + SOURCE_ARCHIVE = 4 + BINARY = 5 + TEST = 6 + DOC = 7 - package_content = models.CharField( - max_length=6, + package_content = models.IntegerField( null=True, choices=PackageContentType.choices, help_text=_( - 'Content of this Package as one of: {}'.format(', '.join(PackageContentType.values)) + 'Content of this Package as one of: {}'.format(', '.join(PackageContentType.labels)) ), )