mirror of
https://github.com/ae-utbm/sith.git
synced 2026-03-13 15:15:03 +00:00
feat: custom through model for Counter.sellers
This commit is contained in:
73
counter/migrations/0038_countersellers.py
Normal file
73
counter/migrations/0038_countersellers.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# 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",
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
]
|
||||
Reference in New Issue
Block a user