# Generated by Django 5.2.4 on 2025-08-22 12:56

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("fileindex", "0003_alter_indexedfile_size_to_biginteger"),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name="indexedfile",
            name="visual_media_requires_dimensions",
        ),
        migrations.RemoveConstraint(
            model_name="indexedfile",
            name="video_requires_frame_rate",
        ),
        migrations.RemoveConstraint(
            model_name="indexedfile",
            name="animated_requires_duration",
        ),
        migrations.AlterField(
            model_name="filepath",
            name="id",
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
        ),
        migrations.AlterField(
            model_name="indexedfile",
            name="id",
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
        ),
        migrations.AddConstraint(
            model_name="indexedfile",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(("corrupt", True), ("corrupt__isnull", False)),
                    models.Q(
                        ("mime_type__startswith", "image/"),
                        ("mime_type__startswith", "video/"),
                        _connector="OR",
                        _negated=True,
                    ),
                    models.Q(("metadata__has_key", "width"), ("metadata__has_key", "height")),
                    models.Q(
                        ("mime_type__startswith", "image/"),
                        ("metadata__image__width__isnull", False),
                        ("metadata__image__height__isnull", False),
                    ),
                    models.Q(
                        ("mime_type__startswith", "video/"),
                        ("metadata__video__width__isnull", False),
                        ("metadata__video__height__isnull", False),
                    ),
                    _connector="OR",
                ),
                name="visual_media_requires_dimensions",
            ),
        ),
        migrations.AddConstraint(
            model_name="indexedfile",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(("corrupt", True), ("corrupt__isnull", False)),
                    models.Q(("mime_type__startswith", "video/"), _negated=True),
                    ("metadata__has_key", "frame_rate"),
                    ("metadata__video__frame_rate__isnull", False),
                    _connector="OR",
                ),
                name="video_requires_frame_rate",
            ),
        ),
        migrations.AddConstraint(
            model_name="indexedfile",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(("corrupt", True), ("corrupt__isnull", False)),
                    models.Q(("metadata__animated", True), _negated=True),
                    models.Q(("metadata__image__animated", True), _negated=True),
                    ("metadata__has_key", "duration"),
                    _connector="OR",
                ),
                name="animated_requires_duration",
            ),
        ),
    ]
