From c801805e57351757a6938e84d217fdf677507a5b Mon Sep 17 00:00:00 2001 From: sudan45 Date: Tue, 2 Jul 2024 11:17:05 +0545 Subject: [PATCH] - Update migrations --- .../migrations/0050_auto_20240621_1149.py | 6 ++++++ .../migrations/0051_auto_20240625_0509.py | 21 +++++++++---------- .../migrations/0010_auto_20240625_0806.py | 10 ++++----- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/lead/migrations/0050_auto_20240621_1149.py b/apps/lead/migrations/0050_auto_20240621_1149.py index 174b45d6ac..4c710310de 100644 --- a/apps/lead/migrations/0050_auto_20240621_1149.py +++ b/apps/lead/migrations/0050_auto_20240621_1149.py @@ -19,4 +19,10 @@ class Migration(migrations.Migration): old_name='LeadPreviewImage', new_name='LeadPreviewAttachment' ), + + migrations.AddField( + model_name='leadpreviewattachment', + name='file_preview', + field=models.FileField(upload_to='lead-preview/attachments-preview/', null=True) + ), ] diff --git a/apps/lead/migrations/0051_auto_20240625_0509.py b/apps/lead/migrations/0051_auto_20240625_0509.py index cece84578e..943ace7d92 100644 --- a/apps/lead/migrations/0051_auto_20240625_0509.py +++ b/apps/lead/migrations/0051_auto_20240625_0509.py @@ -5,11 +5,10 @@ def set_file_preview(apps, schema_editor): LeadPreviewAttachment = apps.get_model('lead', 'LeadPreviewAttachment') - lead_attachments = LeadPreviewAttachment.objects.all() - for lead_attachment in lead_attachments: - lead_attachment.file_preview = lead_attachment.file - lead_attachment.type = 2 # default type is image - lead_attachment.save(updated_fields=['file_preview','type']) + LeadPreviewAttachment.objects.update( + file_preview=models.F('file'), + type=2, + ) class Migration(migrations.Migration): @@ -29,11 +28,6 @@ class Migration(migrations.Migration): name='page_number', field=models.IntegerField(default=0), ), - migrations.AddField( - model_name='leadpreviewattachment', - name='file_preview', - field=models.FileField(upload_to='lead-preview/attachments-preview/') - ), migrations.AddField( model_name='leadpreviewattachment', name='type', @@ -42,5 +36,10 @@ class Migration(migrations.Migration): migrations.RunPython( set_file_preview, reverse_code=migrations.RunPython.noop, - ) + ), + migrations.AlterField( + model_name='leadpreviewattachment', + name='file_preview', + field=models.FileField(upload_to='lead-preview/attachments-preview/') + ), ] diff --git a/apps/unified_connector/migrations/0010_auto_20240625_0806.py b/apps/unified_connector/migrations/0010_auto_20240625_0806.py index fae4142a9d..00e9df78c0 100644 --- a/apps/unified_connector/migrations/0010_auto_20240625_0806.py +++ b/apps/unified_connector/migrations/0010_auto_20240625_0806.py @@ -2,13 +2,13 @@ from django.db import migrations, models + def set_file_preview(apps, schema_editor): ConnectorLeadPreviewAttachment = apps.get_model('unified_connector', 'ConnectorLeadPreviewAttachment') - connector_lead_attachments = ConnectorLeadPreviewAttachment.objects.all() - for connector_lead_attachment in connector_lead_attachments: - connector_lead_attachment.file_preview = connector_lead_attachment.file - connector_lead_attachment.type = 2 # default type is image - connector_lead_attachment.save(updated_fields=['file_preview','type']) + ConnectorLeadPreviewAttachment.objects.update( + file_preview=models.F('file'), + attachment_type=2, + ) class Migration(migrations.Migration):