Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by Django 3.0.8 on 2021-09-30 12:38
- import mptt.fields
- from django.db import migrations, models
- import django.db.models.deletion
- from users.models import Department
- def rebuild_tree(apps, schema_editor):
- """Пересобирает данные дерева для Department"""
- Department.objects.rebuild()
- class Migration(migrations.Migration):
- dependencies = [
- ('users', '0006_remove_position_department'),
- ]
- operations = [
- migrations.AlterModelOptions(
- name='department',
- options={},
- ),
- migrations.AddField(
- model_name='department',
- name='level',
- field=models.PositiveIntegerField(default=0, editable=False),
- preserve_default=False,
- ),
- migrations.AddField(
- model_name='department',
- name='lft',
- field=models.PositiveIntegerField(default=0, editable=False),
- preserve_default=False,
- ),
- migrations.AddField(
- model_name='department',
- name='parent',
- field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='users.Department'),
- ),
- migrations.AddField(
- model_name='department',
- name='rght',
- field=models.PositiveIntegerField(default=0, editable=False),
- preserve_default=False,
- ),
- migrations.AddField(
- model_name='department',
- name='tree_id',
- field=models.PositiveIntegerField(db_index=True, default=0, editable=False),
- preserve_default=False,
- ),
- migrations.RunPython(rebuild_tree),
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement