# Generated by Django 5.2.11 on 2026-03-04 15:26

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("counter", "0037_productformula"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        # cf. https://docs.djangoproject.com/fr/stable/howto/writing-migrations/#changing-a-manytomanyfield-to-use-a-through-model
        migrations.SeparateDatabaseAndState(
            database_operations=[
                migrations.RunSQL(
                    sql="ALTER TABLE counter_counter_sellers RENAME TO counter_countersellers",
                    reverse_sql="ALTER TABLE counter_countersellers RENAME TO counter_counter_sellers",
                ),
            ],
            state_operations=[
                migrations.CreateModel(
                    name="CounterSellers",
                    fields=[
                        (
                            "id",
                            models.AutoField(
                                auto_created=True,
                                primary_key=True,
                                serialize=False,
                                verbose_name="ID",
                            ),
                        ),
                        (
                            "counter",
                            models.ForeignKey(
                                on_delete=django.db.models.deletion.CASCADE,
                                to="counter.counter",
                            ),
                        ),
                        (
                            "user",
                            models.ForeignKey(
                                on_delete=django.db.models.deletion.CASCADE,
                                to=settings.AUTH_USER_MODEL,
                            ),
                        ),
                    ],
                    options={
                        "constraints": [
                            models.UniqueConstraint(
                                fields=("counter", "user"),
                                name="counter_counter_sellers_counter_id_subscriber_id_key",
                            )
                        ],
                    },
                ),
                migrations.AlterField(
                    model_name="counter",
                    name="sellers",
                    field=models.ManyToManyField(
                        blank=True,
                        related_name="counters",
                        through="counter.CounterSellers",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="sellers",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="countersellers",
            name="created_at",
            field=models.DateTimeField(
                auto_now_add=True,
                default=django.utils.timezone.now,
                verbose_name="created at",
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="countersellers",
            name="is_regular",
            field=models.BooleanField(default=False, verbose_name="regular barman"),
        ),
    ]
