dev: back migration to update label colors (#664)

This commit is contained in:
pablohashescobar 2023-04-03 23:58:35 +05:30 committed by GitHub
parent d990f0038b
commit 1bb93f1f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import uuid
import random
from django.contrib.auth.hashers import make_password
from plane.db.models import ProjectIdentifier
from plane.db.models import Issue, IssueComment, User, Project
from plane.db.models import Issue, IssueComment, User, Project, Label
# Update description and description html values for old descriptions
@ -134,3 +134,18 @@ def update_project_cover_images():
except Exception as e:
print(e)
print("Failed")
def update_label_color():
try:
labels = Label.objects.filter(color="")
updated_labels = []
for label in labels:
label.color = "#" + "%06x" % random.randint(0, 0xFFFFFF)
updated_labels.append(label)
Label.objects.bulk_update(updated_labels, ["color"], batch_size=100)
print("Success")
except Exception as e:
print(e)
print("Failed")