mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-18 22:26:34 +00:00
Adds reverse migration stub
This commit is contained in:
parent
e99e4831f1
commit
cb811c92a6
1 changed files with 6 additions and 1 deletions
|
@ -57,16 +57,21 @@ def infer_format(app_registry, schema_editor):
|
|||
}
|
||||
for edition in editions:
|
||||
free_format = editions.physical_format_detail.lower()
|
||||
print(free_format)
|
||||
if free_format in mappings:
|
||||
print("hi")
|
||||
edition.physical_format = mappings[free_format]
|
||||
edition.save(broadcast=False)
|
||||
else:
|
||||
matches = [v for k, v in mappings if k in free_format]
|
||||
print(matches)
|
||||
if not matches:
|
||||
continue
|
||||
edition.physical_format = matches[0]
|
||||
edition.save(broadcast=False)
|
||||
|
||||
def reverse(app_registry, schema_editor):
|
||||
"""doesn't need to do anything"""
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
@ -96,5 +101,5 @@ class Migration(migrations.Migration):
|
|||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.RunPython(infer_format),
|
||||
migrations.RunPython(infer_format, reverse),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue