fix migration chain
This commit is contained in:
parent
31cb9e283a
commit
f76dd86f73
@ -1,70 +0,0 @@
|
|||||||
# Generated by Django 3.1.7 on 2021-03-30 19:42
|
|
||||||
|
|
||||||
from treebeard.mp_tree import MP_Node
|
|
||||||
from django.db import migrations, models
|
|
||||||
from django_scopes import scopes_disabled
|
|
||||||
# update if needed
|
|
||||||
steplen = MP_Node.steplen
|
|
||||||
alphabet = MP_Node.alphabet
|
|
||||||
node_order_by = ["name"]
|
|
||||||
|
|
||||||
|
|
||||||
def update_paths(apps, schema_editor):
|
|
||||||
with scopes_disabled():
|
|
||||||
Node = apps.get_model("cookbook", "Keyword")
|
|
||||||
nodes = Node.objects.all().order_by(*node_order_by)
|
|
||||||
for i, node in enumerate(nodes, 1):
|
|
||||||
# for default values, this resolves to: "{:04d}".format(i)
|
|
||||||
node.path = f"{{:{alphabet[0]}{steplen}d}}".format(i)
|
|
||||||
if nodes:
|
|
||||||
Node.objects.bulk_update(nodes, ["path"])
|
|
||||||
|
|
||||||
|
|
||||||
def backwards(apps, schema_editor):
|
|
||||||
"""nothing to do"""
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('cookbook', '0140_userpreference_created_at'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='keyword',
|
|
||||||
name='depth',
|
|
||||||
field=models.PositiveIntegerField(default=1),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='keyword',
|
|
||||||
name='numchild',
|
|
||||||
field=models.PositiveIntegerField(default=0),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='keyword',
|
|
||||||
name='path',
|
|
||||||
field=models.CharField(default="", max_length=255, unique=False),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='userpreference',
|
|
||||||
name='use_fractions',
|
|
||||||
field=models.BooleanField(default=True),
|
|
||||||
),
|
|
||||||
migrations.RunPython(update_paths, backwards),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name="keyword",
|
|
||||||
name="path",
|
|
||||||
field=models.CharField(max_length=255, unique=True),
|
|
||||||
),
|
|
||||||
migrations.AlterUniqueTogether(
|
|
||||||
name='keyword',
|
|
||||||
unique_together=set(),
|
|
||||||
),
|
|
||||||
migrations.AddConstraint(
|
|
||||||
model_name='keyword',
|
|
||||||
constraint=models.UniqueConstraint(fields=('space', 'name'), name='unique_name_per_space'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -27,7 +27,7 @@ def set_default_search_vector(apps, schema_editor):
|
|||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0141_auto_20210713_1042'),
|
('cookbook', '0142_alter_userpreference_search_style'),
|
||||||
]
|
]
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
@ -13,7 +13,7 @@ def create_searchfields(apps, schema_editor):
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0142_build_full_text_index'),
|
('cookbook', '0143_build_full_text_index'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0143_create_searchfields'),
|
('cookbook', '0144_create_searchfields'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0144_alter_userpreference_search_style'),
|
('cookbook', '0145_alter_userpreference_search_style'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
@ -27,7 +27,7 @@ def backwards(apps, schema_editor):
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0145_alter_userpreference_use_fractions'),
|
('cookbook', '0146_alter_userpreference_use_fractions'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0146_keyword_to_tree'),
|
('cookbook', '0147_keyword_to_tree'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
@ -23,7 +23,7 @@ def backwards(apps, schema_editor):
|
|||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('cookbook', '0147_auto_20210813_1829'),
|
('cookbook', '0148_auto_20210813_1829'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
Loading…
Reference in New Issue
Block a user