3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-24 20:33:12 +00:00
coope/gestion/migrations/0007_auto_20190503_1841.py
2019-05-03 21:09:32 +02:00

46 lines
1.6 KiB
Python

# Generated by Django 2.1 on 2019-05-03 16:41
from django.db import migrations, models
import django.db.models.deletion
def create_default_category(apps, schema_editor):
Category = apps.get_model('gestion', 'Category')
new_category = Category(name="Autre")
new_category.save()
class Migration(migrations.Migration):
dependencies = [
('gestion', '0006_auto_20190227_0859'),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True, verbose_name='Nom')),
],
),
migrations.RemoveField(
model_name='historicalproduct',
name='category',
),
migrations.RemoveField(
model_name='product',
name='category',
),
migrations.RunPython(create_default_category),
migrations.AddField(
model_name='historicalproduct',
name='category',
field=models.ForeignKey(default=1, blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='gestion.Category'),
preserve_default=False,
),
migrations.AddField(
model_name='product',
name='category',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, to='gestion.Category'),
preserve_default=False,
),
]