Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
65 lines
2.0 KiB
Python
65 lines
2.0 KiB
Python
# Generated by Django 4.2.15 on 2024-10-09 06:19
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def move_attachment_to_fileasset(apps, schema_editor):
|
|
FileAsset = apps.get_model("db", "FileAsset")
|
|
IssueAttachment = apps.get_model("db", "IssueAttachment")
|
|
|
|
bulk_issue_attachment = []
|
|
for issue_attachment in IssueAttachment.objects.values(
|
|
"issue_id",
|
|
"project_id",
|
|
"workspace_id",
|
|
"asset",
|
|
"attributes",
|
|
"external_source",
|
|
"external_id",
|
|
"deleted_at",
|
|
"created_by_id",
|
|
"updated_by_id",
|
|
):
|
|
bulk_issue_attachment.append(
|
|
FileAsset(
|
|
issue_id=issue_attachment["issue_id"],
|
|
entity_type="ISSUE_ATTACHMENT",
|
|
project_id=issue_attachment["project_id"],
|
|
workspace_id=issue_attachment["workspace_id"],
|
|
attributes=issue_attachment["attributes"],
|
|
asset=issue_attachment["asset"],
|
|
external_source=issue_attachment["external_source"],
|
|
external_id=issue_attachment["external_id"],
|
|
deleted_at=issue_attachment["deleted_at"],
|
|
created_by_id=issue_attachment["created_by_id"],
|
|
updated_by_id=issue_attachment["updated_by_id"],
|
|
size=issue_attachment["attributes"].get("size", 0),
|
|
)
|
|
)
|
|
|
|
FileAsset.objects.bulk_create(bulk_issue_attachment, batch_size=1000)
|
|
|
|
|
|
def mark_existing_file_uploads(apps, schema_editor):
|
|
FileAsset = apps.get_model("db", "FileAsset")
|
|
# Mark all existing file uploads as uploaded
|
|
FileAsset.objects.update(is_uploaded=True)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("db", "0078_fileasset_comment_fileasset_entity_type_and_more"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(
|
|
move_attachment_to_fileasset,
|
|
reverse_code=migrations.RunPython.noop,
|
|
),
|
|
migrations.RunPython(
|
|
mark_existing_file_uploads,
|
|
reverse_code=migrations.RunPython.noop,
|
|
),
|
|
]
|