# Generated by Django 5.2.9 on 2026-02-08 12:14

import django.contrib.postgres.indexes
import django.core.validators
import django.db.models.deletion
import parler.models
import uuid
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('order', '0024_add_payment_method_fee'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='LoyaltyTier',
            fields=[
                ('sort_order', models.IntegerField(editable=False, null=True, verbose_name='Sort Order')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('required_level', models.PositiveIntegerField(help_text='Minimum level to achieve this tier', unique=True, verbose_name='Required Level')),
                ('points_multiplier', models.DecimalField(decimal_places=2, default=Decimal('1.0'), help_text='Multiplier applied to earned points for users in this tier', max_digits=5, validators=[django.core.validators.MinValueValidator(Decimal('1.0'))], verbose_name='Points Multiplier')),
            ],
            options={
                'verbose_name': 'Loyalty Tier',
                'verbose_name_plural': 'Loyalty Tiers',
                'db_table': 'loyalty_tier',
                'ordering': ['required_level'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='loyaltytier_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='loyaltytier_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['sort_order'], name='loyaltytier_sort_order_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['required_level'], name='loyalty_tier_req_lvl_ix')],
            },
            bases=(parler.models.TranslatableModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name='LoyaltyTierTranslation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('language_code', models.CharField(db_index=True, max_length=15, verbose_name='Language')),
                ('name', models.CharField(max_length=100, verbose_name='Name')),
                ('description', models.TextField(blank=True, default='', verbose_name='Description')),
                ('master', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='loyalty.loyaltytier')),
            ],
            options={
                'db_table': 'loyalty_tier_translation',
                'unique_together': {('language_code', 'master')},
            },
            bases=(parler.models.TranslatedFieldsModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PointsTransaction',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('points', models.IntegerField(help_text='Positive for earn/bonus, negative for redeem/expire/adjust', verbose_name='Points')),
                ('transaction_type', models.CharField(choices=[('EARN', 'Earn'), ('REDEEM', 'Redeem'), ('EXPIRE', 'Expire'), ('ADJUST', 'Adjust'), ('BONUS', 'Bonus')], max_length=10, verbose_name='Transaction Type')),
                ('description', models.TextField(blank=True, default='', verbose_name='Description')),
                ('created_by', models.ForeignKey(blank=True, help_text='Admin user who created this adjustment', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='points_adjustments_made', to=settings.AUTH_USER_MODEL)),
                ('reference_order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='points_transactions', to='order.order')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='points_transactions', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Points Transaction',
                'verbose_name_plural': 'Points Transactions',
                'db_table': 'loyalty_points_transaction',
                'ordering': ['-created_at'],
                'indexes': [django.contrib.postgres.indexes.BTreeIndex(fields=['created_at'], name='pointstransaction_created_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['updated_at'], name='pointstransaction_updated_at_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['user'], name='loyalty_tx_user_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['transaction_type'], name='loyalty_tx_type_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['reference_order'], name='loyalty_tx_order_ix'), django.contrib.postgres.indexes.BTreeIndex(fields=['user', 'transaction_type'], name='loyalty_tx_user_type_ix')],
            },
        ),
    ]
