# Generated by Django 4.2.18 on 2025-02-11 15:57

import pgtrigger.compiler
import pgtrigger.migrations
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ('db', '0129_filestore_total_size'),
    ]

    operations = [
        migrations.AlterField(
            model_name='filestore',
            name='total_size',
            field=models.BigIntegerField(default=0, editable=False),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name='fileinstore',
            trigger=pgtrigger.compiler.Trigger(
                name='db_fileinstore_total_size_insert',
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='UPDATE db_filestore SET total_size = total_size + db_file.size FROM db_file WHERE db_filestore.id = NEW.store_id AND db_file.id = NEW.file_id; RETURN NULL;',
                    hash='93dd6bf857752d47e15ce24887b0151f07f5aa77',
                    operation='INSERT',
                    pgid='pgtrigger_db_fileinstore_total_size_insert_8cd7f',
                    table='db_fileinstore',
                    when='AFTER',
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name='fileinstore',
            trigger=pgtrigger.compiler.Trigger(
                name='db_fileinstore_total_size_delete',
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='UPDATE db_filestore SET total_size = total_size - db_file.size FROM db_file WHERE db_filestore.id = OLD.store_id AND db_file.id = OLD.file_id; RETURN NULL;',
                    hash='1d8bad11847895fe36cd12b11d4f1a10fd451da7',
                    operation='DELETE',
                    pgid='pgtrigger_db_fileinstore_total_size_delete_07c98',
                    table='db_fileinstore',
                    when='AFTER',
                ),
            ),
        ),
    ]
