# Generated by Django 4.2.7 on 2025-12-19 09:16

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
    dependencies = [
        ("subscriptions", "0006_make_price_per_student_required"),
    ]

    operations = [
        migrations.CreateModel(
            name="DurationDiscount",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "duration_days",
                    models.IntegerField(
                        help_text="Количество дней подписки (30, 90, 180, 365)",
                        validators=[django.core.validators.MinValueValidator(1)],
                        verbose_name="Длительность в днях",
                    ),
                ),
                (
                    "discount_percent",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Процент скидки за эту длительность (например, 7.00 для 7%)",
                        max_digits=5,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name="Процент скидки",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Дата создания"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Дата обновления"),
                ),
                (
                    "plan",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="duration_discounts",
                        to="subscriptions.subscriptionplan",
                        verbose_name="Тарифный план",
                    ),
                ),
            ],
            options={
                "verbose_name": "Скидка за длительность",
                "verbose_name_plural": "Скидки за длительность",
                "db_table": "duration_discounts",
                "ordering": ["plan", "duration_days"],
                "indexes": [
                    models.Index(
                        fields=["plan", "duration_days"],
                        name="duration_di_plan_id_3eb246_idx",
                    )
                ],
                "unique_together": {("plan", "duration_days")},
            },
        ),
    ]
