# Generated by Django 5.1.12 on 2025-09-19 11:54

from django.db import migrations, models


def set_size_compressed(apps, schema_editor):
    Blob = apps.get_model('core', 'Blob')
    queryset = Blob.objects.only("raw_content", "size_compressed").filter(size_compressed=0)
    for blob in queryset.iterator(chunk_size=10):
        blob.size_compressed = len(blob.raw_content)
        blob.save(update_fields=["size_compressed"])


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0006_mailboxaccess_accessed_at_alter_message_draft_blob'),
    ]

    operations = [
        migrations.AddField(
            model_name='blob',
            name='size_compressed',
            field=models.PositiveIntegerField(default=0, help_text='Size of the compressed blob in bytes', verbose_name='compressed size'),
            preserve_default=False,
        ),
        migrations.RunPython(set_size_compressed, reverse_code=migrations.RunPython.noop, atomic=False),
    ]
