moviewyrm/bookwyrm/migrations/0035_edition_edition_rank.py

28 lines
726 B
Python
Raw Normal View History

2021-01-11 17:18:40 +00:00
# Generated by Django 3.0.7 on 2021-01-11 17:18
import bookwyrm.models.fields
from django.db import migrations
2021-01-11 17:29:23 +00:00
def set_rank(app_registry, schema_editor):
db_alias = schema_editor.connection.alias
books = app_registry.get_model('bookwyrm', 'Edition')
for book in books.objects.using(db_alias):
book.edition_rank = book.get_rank
2021-01-11 17:29:23 +00:00
book.save()
2021-01-11 17:18:40 +00:00
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0034_importjob_complete'),
]
operations = [
migrations.AddField(
model_name='edition',
name='edition_rank',
field=bookwyrm.models.fields.IntegerField(default=0),
),
2021-01-11 17:29:23 +00:00
migrations.RunPython(set_rank),
2021-01-11 17:18:40 +00:00
]