# Generated by Django 4.2.16 on 2026-11-06 13:26 from decimal import Decimal from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('orders', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='BonusAccount', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('balance', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='bonus_account', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'бонусный счёт', 'verbose_name_plural': 'бонусные счета', 'db_table': 'loyalty_bonus_account', }, ), migrations.CreateModel( name='PromoCode', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('code', models.CharField(max_length=64, unique=True)), ('discount_type', models.CharField(choices=[('percent', 'Процент'), ('fixed', 'Фиксированная сумма')], max_length=10)), ('value', models.DecimalField(decimal_places=2, max_digits=12)), ('min_order_total', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)), ('valid_from', models.DateTimeField(blank=True, null=True)), ('valid_to', models.DateTimeField(blank=True, null=True)), ('max_uses', models.PositiveIntegerField(blank=True, null=True)), ('used_count', models.PositiveIntegerField(default=0)), ('is_active', models.BooleanField(default=True)), ], options={ 'verbose_name': 'промокод', 'verbose_name_plural': 'промокоды', 'db_table': 'loyalty_promo_code', 'ordering': ['-created_at'], }, ), migrations.CreateModel( name='GiftCertificate', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('code', models.CharField(max_length=64, unique=True)), ('nominal', models.DecimalField(decimal_places=2, max_digits=12)), ('balance', models.DecimalField(decimal_places=2, max_digits=12)), ('status', models.CharField(choices=[('issued', 'Выпущен'), ('active', 'Активен'), ('used', 'Использован'), ('expired', 'Истёк')], default='issued', max_length=20)), ('expires_at', models.DateTimeField(blank=True, null=True)), ('issued_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='certificates', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'подарочный сертификат', 'verbose_name_plural': 'подарочные сертификаты', 'db_table': 'loyalty_gift_certificate', 'ordering': ['-created_at'], }, ), migrations.CreateModel( name='BonusTransaction', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('amount', models.DecimalField(decimal_places=2, max_digits=12)), ('reason', models.CharField(choices=[('accrual', 'Начисление'), ('spend', 'Списание'), ('refund', 'Возврат'), ('adjustment', 'Корректировка')], max_length=20)), ('comment', models.CharField(blank=True, max_length=255)), ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transactions', to='loyalty.bonusaccount')), ('order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='bonus_transactions', to='orders.order')), ], options={ 'verbose_name': 'бонусная операция', 'verbose_name_plural': 'бонусные операции', 'db_table': 'loyalty_bonus_transaction', 'ordering': ['-created_at'], }, ), ]