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

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', '0017_order_metadata_order_private_metadata'),
        ('product', '0026_productcategory_product_productcategory_tr16fb'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='StockReservation',
            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)),
                ('quantity', models.PositiveIntegerField(help_text='Number of units reserved', verbose_name='Quantity')),
                ('session_id', models.CharField(help_text='Cart UUID or session identifier for tracking', max_length=255, verbose_name='Session ID')),
                ('expires_at', models.DateTimeField(help_text='Timestamp when reservation expires (typically 15 minutes from creation)', verbose_name='Expires At')),
                ('consumed', models.BooleanField(default=False, help_text='True if reservation was converted to actual stock decrement', verbose_name='Consumed')),
                ('order', models.ForeignKey(blank=True, help_text='Order created from this reservation (set when consumed)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_reservations', to='order.order')),
                ('product', models.ForeignKey(help_text='Product being reserved', on_delete=django.db.models.deletion.CASCADE, related_name='stock_reservations', to='product.product')),
                ('reserved_by', models.ForeignKey(blank=True, help_text='User who made the reservation (null for guest users)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_reservations', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Stock Reservation',
                'verbose_name_plural': 'Stock Reservations',
                'ordering': ['-created_at'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='stockreservation_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='stockreservation_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['product', 'consumed'], name='stock_res_product_consumed_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['expires_at', 'consumed'], name='stock_res_expires_consumed_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['session_id'], name='stock_res_session_id_ix')],
            },
        ),
    ]
