Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/+description-field-clash.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed `description` field from models subclassing `Distribution` to fix field clash error when using pulpcore>=3.106.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated manually to migrate description fields from subclasses to parent Distribution class

from django.db import migrations


def migrate_description_data_forward(apps, schema_editor):
Distribution = apps.get_model("core", "Distribution")
ContainerDistribution = apps.get_model("container", "ContainerDistribution")
ContainerPullThroughDistribution = apps.get_model(
"container", "ContainerPullThroughDistribution"
)

for Model in (ContainerDistribution, ContainerPullThroughDistribution):
for dist in Model.objects.all():
if dist.description:
parent = Distribution.objects.get(pk=dist.pk)
if not parent.description:
parent.description = dist.description
parent.save(update_fields=["description"])


class Migration(migrations.Migration):

dependencies = [
# Ensure parent field exists before copying data
("core", "0146_distribution_description"),
("container", "0047_containernamespace_pulp_labels"),
]

operations = [
# Copy description data from subclass tables to parent Distribution table
migrations.RunPython(migrate_description_data_forward, migrations.RunPython.noop),
# Remove duplicate fields from subclasses
migrations.RemoveField(model_name="containerdistribution", name="description"),
migrations.RemoveField(model_name="containerpullthroughdistribution", name="description"),
]
2 changes: 0 additions & 2 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ class ContainerPullThroughDistribution(Distribution, AutoAddObjPermsMixin):
"Defaults to unrestricted pull access."
),
)
description = models.TextField(null=True)

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
Expand Down Expand Up @@ -878,7 +877,6 @@ class ContainerDistribution(Distribution, AutoAddObjPermsMixin):
"Defaults to unrestricted pull access."
),
)
description = models.TextField(null=True)

pull_through_distribution = models.ForeignKey(
ContainerPullThroughDistribution,
Expand Down
8 changes: 0 additions & 8 deletions pulp_container/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ class ContainerDistributionSerializer(DistributionSerializer, GetOrCreateSeriali
view_name="pulp_container/namespaces-detail",
help_text=_("Namespace this distribution belongs to."),
)
description = serializers.CharField(
help_text=_("An optional description."), required=False, allow_null=True
)
repository_version = RepositoryVersionRelatedField(
required=False, help_text=_("RepositoryVersion to be served"), allow_null=True
)
Expand Down Expand Up @@ -487,7 +484,6 @@ class Meta:
"remote",
"namespace",
"private",
"description",
)


Expand Down Expand Up @@ -521,9 +517,6 @@ class ContainerPullThroughDistributionSerializer(DistributionSerializer):
queryset=models.ContainerDistribution.objects.all(),
required=False,
)
description = serializers.CharField(
help_text=_("An optional description."), required=False, allow_null=True
)

def validate(self, data):
validated_data = super().validate(data)
Expand All @@ -549,7 +542,6 @@ class Meta:
"distributions",
"namespace",
"private",
"description",
)


Expand Down
Loading