mirror of
https://github.com/nanoy42/coope
synced 2024-12-25 00:13:46 +00:00
46 lines
1.6 KiB
Python
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,
|
|
),
|
|
]
|