# Generated by Django 5.2 on 2025-09-19 14:09

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0137_organizationbilling_max_extra_tasks_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='meteringbatch',
            name='organization',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='metering_batches', to='api.organization'),
        ),
        migrations.AlterField(
            model_name='meteringbatch',
            name='user',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='metering_batches', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddIndex(
            model_name='meteringbatch',
            index=models.Index(fields=['organization', 'created_at'], name='meter_batch_org_ts_idx'),
        ),
        migrations.AddConstraint(
            model_name='meteringbatch',
            constraint=models.CheckConstraint(condition=models.Q(models.Q(('organization__isnull', True), ('user__isnull', False)), models.Q(('organization__isnull', False), ('user__isnull', True)), _connector='OR'), name='metering_batch_owner_xor'),
        ),
    ]
