-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[WEB-5312] migration: reply for work item comments #8072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sangeethailango
wants to merge
12
commits into
preview
Choose a base branch
from
chore-description-in-issue-comment
base: preview
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+412
−1
Open
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df965a7
migration: description field on issue_comment
sangeethailango 0987943
fix: update if description already exists for the IssueComment
sangeethailango ac85e59
feat: management command to copy IssueComment to Description
sangeethailango 69120b8
fix: description creation order
sangeethailango 8a72d2a
chore: add while loop
sangeethailango ea1e95c
fix: move write outside loop
sangeethailango f18e120
chore: change sync logic
sangeethailango 24f8010
chore: removed deleted_at filter and added order_by in management com…
sangeethailango 0daf524
fix: description_id
sangeethailango c65d2ff
migration: added parent_id for IssueComment
sangeethailango 6095f86
fix: update update_by_id
sangeethailango a86753e
Merge branch 'preview' into chore-description-in-issue-comment
sangeethailango File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
apps/api/plane/db/management/commands/copy_issue_comment_to_description.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Django imports | ||
| from django.core.management.base import BaseCommand | ||
| from django.db import transaction | ||
|
|
||
| # Module imports | ||
| from plane.db.models import Description | ||
| from plane.db.models import IssueComment | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
| help = "Create Description records for existing IssueComment" | ||
|
|
||
| def handle(self, *args, **kwargs): | ||
| batch_size = 500 | ||
|
|
||
| while True: | ||
| comments = list( | ||
| IssueComment.objects.filter(deleted_at__isnull=True, description_id__isnull=True)[:batch_size] | ||
| ) | ||
| if not comments: | ||
| break | ||
|
|
||
| with transaction.atomic(): | ||
| descriptions = [ | ||
| Description( | ||
| created_at=comment.created_at, | ||
| updated_at=comment.updated_at, | ||
| description_json=comment.comment_json, | ||
| description_html=comment.comment_html, | ||
| description_stripped=comment.comment_stripped, | ||
| project_id=comment.project_id, | ||
| created_by_id=comment.created_by_id, | ||
| updated_by_id=comment.updated_by_id, | ||
| workspace_id=comment.workspace_id, | ||
| ) | ||
| for comment in comments | ||
| ] | ||
|
|
||
| created_descriptions = Description.objects.bulk_create(descriptions) | ||
|
|
||
| comments_to_update = [] | ||
| for comment, description in zip(comments, created_descriptions): | ||
| comment.description_id = description.id | ||
| comments_to_update.append(comment) | ||
|
|
||
| IssueComment.objects.bulk_update(comments_to_update, ["description_id"]) | ||
|
|
||
| self.stdout.write(self.style.SUCCESS("Successfully Copied IssueComment to Description")) | ||
19 changes: 19 additions & 0 deletions
19
apps/api/plane/db/migrations/0109_issuecomment_description.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Generated by Django 4.2.22 on 2025-11-06 08:28 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('db', '0108_alter_issueactivity_issue_comment'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='issuecomment', | ||
| name='description', | ||
| field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='issue_comment_description', to='db.description'), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.