feat: move errata tags
This commit is contained in:
parent
8732dcb706
commit
092e572e16
29
ietf/doc/migrations/0019_move_errata_tags.py
Normal file
29
ietf/doc/migrations/0019_move_errata_tags.py
Normal file
|
@ -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)]
|
Loading…
Reference in a new issue