moviewyrm/bookwyrm/migrations/0035_edition_edition_rank.py
Joel Bradshaw ec2a43faa5 Fix error in migrations
I was getting the following error when running 0035:
AttributeError: 'Edition' object has no attribute 'get_rank',

But that line seems to be unnecessary, since save() does the same thing,
and we are already calling that.
2021-01-13 18:37:05 -08:00

26 lines
684 B
Python

# Generated by Django 3.0.7 on 2021-01-11 17:18
import bookwyrm.models.fields
from django.db import migrations
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.save()
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),
),
migrations.RunPython(set_rank),
]