fix: back migration for identifiers without workspaces (#212)

This commit is contained in:
pablohashescobar 2023-01-31 19:49:02 +05:30 committed by GitHub
parent eaa77a2552
commit 0cb4edab54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
# All the python scripts that are used for back migrations
from plane.db.models import ProjectIdentifier
from plane.db.models import Issue, IssueComment
# Update description and description html values for old descriptions
@ -40,3 +40,21 @@ def update_comments():
except Exception as e:
print(e)
print("Failed")
def update_project_identifiers():
try:
project_identifiers = ProjectIdentifier.objects.filter(workspace_id=None).select_related("project", "project__workspace")
updated_identifiers = []
for identifier in project_identifiers:
identifier.workspace_id = identifier.project.workspace_id
updated_identifiers.append(identifier)
ProjectIdentifier.objects.bulk_update(
updated_identifiers, ["workspace_id"], batch_size=50
)
print("Success")
except Exception as e:
print(e)
print("Failed")