From 1bb93f1f5030bc4e41e03ea50e15198a7c2900c0 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:58:35 +0530 Subject: [PATCH] dev: back migration to update label colors (#664) --- apiserver/back_migration.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apiserver/back_migration.py b/apiserver/back_migration.py index 93f07134f..ff5fc74e4 100644 --- a/apiserver/back_migration.py +++ b/apiserver/back_migration.py @@ -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")