# Generated by Django 5.2.9 on 2026-01-21 15:46

import django.contrib.postgres.indexes
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('order', '0018_stockreservation'),
        ('product', '0026_productcategory_product_productcategory_tr16fb'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='StockLog',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('operation_type', models.CharField(choices=[('RESERVE', 'Reserve'), ('RELEASE', 'Release'), ('DECREMENT', 'Decrement'), ('INCREMENT', 'Increment')], help_text='Type of stock operation performed', max_length=50, verbose_name='Operation Type')),
                ('quantity_delta', models.IntegerField(help_text='Change in quantity (positive for increment, negative for decrement)', verbose_name='Quantity Delta')),
                ('stock_before', models.IntegerField(help_text='Stock level before the operation', verbose_name='Stock Before')),
                ('stock_after', models.IntegerField(help_text='Stock level after the operation', verbose_name='Stock After')),
                ('reason', models.CharField(help_text='Human-readable reason for the stock change', max_length=255, verbose_name='Reason')),
                ('order', models.ForeignKey(blank=True, help_text='Order associated with this stock operation (if applicable)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_logs', to='order.order')),
                ('performed_by', models.ForeignKey(blank=True, help_text='User who performed the operation (null for system operations)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_operations', to=settings.AUTH_USER_MODEL)),
                ('product', models.ForeignKey(help_text='Product whose stock was modified', on_delete=django.db.models.deletion.CASCADE, related_name='stock_logs', to='product.product')),
            ],
            options={
                'verbose_name': 'Stock Log',
                'verbose_name_plural': 'Stock Logs',
                'ordering': ['-created_at'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='stocklog_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='stocklog_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['product', 'created_at'], name='stock_log_product_created_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['order'], name='stock_log_order_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['operation_type'], name='stock_log_operation_type_ix')],
            },
        ),
    ]
