Skip to content

Commit

Permalink
Update package_set and package_content #95
Browse files Browse the repository at this point in the history
    * package_set is now a UUIDField
    * package_content is now an IntegerField

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed May 17, 2023
1 parent 172494c commit 660e0c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packagedb/migrations/0065_set_package_content_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
22 changes: 13 additions & 9 deletions packagedb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
),
)

Expand Down

0 comments on commit 660e0c7

Please sign in to comment.