Skip to content

Commit

Permalink
- Update migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Jul 2, 2024
1 parent 0350cdc commit c801805
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
6 changes: 6 additions & 0 deletions apps/lead/migrations/0050_auto_20240621_1149.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
),
]
21 changes: 10 additions & 11 deletions apps/lead/migrations/0051_auto_20240625_0509.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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',
Expand All @@ -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/')
),
]
10 changes: 5 additions & 5 deletions apps/unified_connector/migrations/0010_auto_20240625_0806.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c801805

Please sign in to comment.