Skip to content

Commit

Permalink
Add a migration to check for pending datarepair
Browse files Browse the repository at this point in the history
fixes pulp#141
  • Loading branch information
mdellweg committed Sep 12, 2023
1 parent 4e72167 commit 0b03125
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/141.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a migration to tell admins to run certain datarepair commands before upgrading to 0.4.
25 changes: 25 additions & 0 deletions pulp_gem/app/migrations/0009_check_datarepair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.1 on 2023-08-15 12:44

from django.db import migrations
from pulpcore.migrations import RequireVersion


def check_datarepair(apps, schema_editor):
ShallowGemContent = apps.get_model("gem", "ShallowGemContent")
if ShallowGemContent.objects.exists():
raise RuntimeError("Before continuing with this upgrade, you need to run the 'datarepair-shallow-gems' command, or remove all remaining broken repository versions.")

GemContent = apps.get_model("gem", "GemContent")
if GemContent.objects.filter(platform=None).exists():
raise RuntimeError("Before continuing with this upgrade, you need to run the 'datarepair-gemspec-platform' command, or remove all remaining broken repository versions.")


class Migration(migrations.Migration):
dependencies = [
("gem", "0008_gemcontent_platform"),
]

operations = [
RequireVersion("gem", "0.2.0"),
migrations.RunPython(code=check_datarepair, reverse_code=migrations.RunPython.noop, elidable=True),
]
2 changes: 1 addition & 1 deletion pulp_gem/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class GemRepository(Repository):
"""

TYPE = "gem"
CONTENT_TYPES = [GemContent, ShallowGemContent]
CONTENT_TYPES = [GemContent]
REMOTE_TYPES = [GemRemote]

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulpcore>=3.28.0,<3.40
pulpcore>=3.34.0,<3.40
rubymarshal>=1.2.7,<1.3

0 comments on commit 0b03125

Please sign in to comment.