# Generated by Django 5.2.4 on 2025-07-29 06:41

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='BulkTask',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('async_backend', models.CharField(blank=True, choices=[('q2', 'Django-Q2'), ('celery', 'Celery')], help_text='Async backend used for this task', max_length=20, null=True)),
                ('model_name', models.CharField(help_text='Name of the model being processed', max_length=100)),
                ('operation', models.CharField(choices=[('update', 'Update'), ('delete', 'Delete')], help_text='Type of bulk operation', max_length=20)),
                ('total_records', models.IntegerField(help_text='Total number of records to process')),
                ('processed_records', models.IntegerField(default=0, help_text='Number of records processed so far')),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('STARTED', 'Started'), ('SUCCESS', 'Success'), ('FAILURE', 'Failed')], db_index=True, default='PENDING', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('started_at', models.DateTimeField(blank=True, null=True)),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('error_message', models.TextField(blank=True, help_text='Error details if the operation failed')),
                ('task_key', models.CharField(db_index=True, help_text='Unique key to prevent duplicate operations', max_length=255)),
                ('unique_model_key', models.CharField(db_index=True, max_length=255)),
                ('operation_data', models.JSONField(blank=True, default=dict, help_text='Serialized data about the operation (fields, values, etc.)', null=True)),
                ('user', models.ForeignKey(blank=True, help_text='User who initiated the bulk operation', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Bulk Task',
                'verbose_name_plural': 'Bulk Tasks',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['user', 'status'], name='powercrud_b_user_id_26614c_idx'), models.Index(fields=['task_key'], name='powercrud_b_task_ke_767629_idx'), models.Index(fields=['created_at'], name='powercrud_b_created_d09661_idx')],
            },
        ),
    ]
