save raw_mails as file
This commit is contained in:
parent
6657c54e4a
commit
b2323f2c48
1 changed files with 36 additions and 0 deletions
36
core/mail/migrations/0007_email_raw_file.py
Normal file
36
core/mail/migrations/0007_email_raw_file.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Generated by Django 4.2.7 on 2024-11-08 20:37
|
||||
from django.core.files.base import ContentFile
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mail', '0006_alter_eventaddress_address'),
|
||||
]
|
||||
|
||||
def move_raw_mails_to_file(apps, schema_editor):
|
||||
Email = apps.get_model('mail', 'Email')
|
||||
for email in Email.objects.all():
|
||||
raw_content = email.raw
|
||||
email.raw_file = ContentFile(raw_content)
|
||||
email.raw = None
|
||||
email.save()
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='email',
|
||||
name='raw_file',
|
||||
field=models.FileField(null=True, upload_to='raw_mail/'),
|
||||
),
|
||||
migrations.RunPython(move_raw_mails_to_file),
|
||||
migrations.RemoveField(
|
||||
model_name='email',
|
||||
name='raw',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='email',
|
||||
name='raw_file',
|
||||
field=models.FileField(upload_to='raw_mail/'),
|
||||
),
|
||||
]
|
Loading…
Reference in a new issue