Skip to content

Commit

Permalink
feat: move errata tags
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks committed Sep 22, 2023
1 parent 8732dcb commit 092e572
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ietf/doc/migrations/0019_move_errata_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright The IETF Trust 2023, All Rights Reserved

from django.db import migrations

from django.db.models import Subquery, OuterRef, F


def forward(apps, schema_editor):
Document = apps.get_model("doc", "Document")
RelatedDocument = apps.get_model("doc", "RelatedDocument")
Document.tags.through.objects.filter(
doctagname_id__in=["errata", "verified-errata"], document__type_id="draft"
).annotate(
rfcdoc=Subquery(
RelatedDocument.objects.filter(
relationship_id="became_rfc", source_id=OuterRef("document__pk")
).values_list("target__pk", flat=True)[:1]
)
).update(
document_id=F("rfcdoc")
)


class Migration(migrations.Migration):
dependencies = [
("doc", "0018_subseries"),
]

operations = [migrations.RunPython(forward)]

0 comments on commit 092e572

Please sign in to comment.