-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: re-split migrations into two different files (#2268)
* dev: split issue activity migration separate files * dev: resplit migrations into two different files * dev: changed the batch size
- Loading branch information
1 parent
52b57b1
commit 6e0999c
Showing
3 changed files
with
71 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,26 @@ | ||
# Generated by Django 4.2.5 on 2023-09-26 10:15 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_issue_activity(apps, schema_editor): | ||
IssueActivity = apps.get_model("db", "IssueActivity") | ||
updated_issue_activity = [] | ||
for obj in IssueActivity.objects.all(): | ||
obj.epoch = int(obj.created_at.timestamp()) | ||
updated_issue_activity.append(obj) | ||
IssueActivity.objects.bulk_update( | ||
updated_issue_activity, | ||
["epoch"], | ||
batch_size=5000, | ||
) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('db', '0045_auto_20230915_0655'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_issue_activity), | ||
] |
This file contains 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,44 @@ | ||
# Generated by Django 4.2.5 on 2023-09-26 10:29 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_issue_activity_priority(apps, schema_editor): | ||
IssueActivity = apps.get_model("db", "IssueActivity") | ||
updated_issue_activity = [] | ||
for obj in IssueActivity.objects.filter(field="priority"): | ||
# Set the old and new value to none if it is empty for Priority | ||
obj.new_value = obj.new_value or "none" | ||
obj.old_value = obj.old_value or "none" | ||
updated_issue_activity.append(obj) | ||
IssueActivity.objects.bulk_update( | ||
updated_issue_activity, | ||
["new_value", "old_value"], | ||
batch_size=1000, | ||
) | ||
|
||
def update_issue_activity_blocked(apps, schema_editor): | ||
IssueActivity = apps.get_model("db", "IssueActivity") | ||
updated_issue_activity = [] | ||
for obj in IssueActivity.objects.filter(field="blocks"): | ||
# Set the field to blocked_by | ||
obj.field = "blocked_by" | ||
updated_issue_activity.append(obj) | ||
IssueActivity.objects.bulk_update( | ||
updated_issue_activity, | ||
["field"], | ||
batch_size=1000, | ||
) | ||
|
||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('db', '0046_auto_20230926_1015'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_issue_activity_priority), | ||
migrations.RunPython(update_issue_activity_blocked), | ||
] |
6e0999c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
plane-sh-dev – ./space/
plane-space-dev.vercel.app
plane-sh-dev-plane.vercel.app
plane-sh-dev-git-develop-plane.vercel.app
6e0999c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
plane-dev – ./web/
plane-dev-plane.vercel.app
plane-dev.vercel.app
plane-dev-git-develop-plane.vercel.app