forked from github/plane
feat: back migration script to populate random sort_order values
This commit is contained in:
parent
2505417dbd
commit
eba0f02aeb
@ -1,8 +1,9 @@
|
|||||||
# All the python scripts that are used for back migrations
|
# All the python scripts that are used for back migrations
|
||||||
import uuid
|
import uuid
|
||||||
|
import random
|
||||||
|
from django.contrib.auth.hashers import make_password
|
||||||
from plane.db.models import ProjectIdentifier
|
from plane.db.models import ProjectIdentifier
|
||||||
from plane.db.models import Issue, IssueComment, User
|
from plane.db.models import Issue, IssueComment, User
|
||||||
from django.contrib.auth.hashers import make_password
|
|
||||||
|
|
||||||
|
|
||||||
# Update description and description html values for old descriptions
|
# Update description and description html values for old descriptions
|
||||||
@ -79,3 +80,19 @@ def update_user_empty_password():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("Failed")
|
print("Failed")
|
||||||
|
|
||||||
|
|
||||||
|
def updated_issue_sort_order():
|
||||||
|
try:
|
||||||
|
issues = Issue.objects.all()
|
||||||
|
updated_issues = []
|
||||||
|
|
||||||
|
for issue in issues:
|
||||||
|
issue.sort_order = issue.sequence_id * random.randint(100, 500)
|
||||||
|
updated_issues.append(issue)
|
||||||
|
|
||||||
|
Issue.objects.bulk_update(updated_issues, ["sort_order"], batch_size=100)
|
||||||
|
print("Success")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
print("Failed")
|
||||||
|
Loading…
Reference in New Issue
Block a user