moviewyrm/bookwyrm/migrations/0011_auto_20201113_1727.py
2021-03-08 08:49:10 -08:00

34 lines
944 B
Python

# Generated by Django 3.0.7 on 2020-11-13 17:27
from django.db import migrations, models
def set_origin_id(app_registry, schema_editor):
db_alias = schema_editor.connection.alias
books = app_registry.get_model("bookwyrm", "Book").objects.using(db_alias)
for book in books:
book.origin_id = book.remote_id
# the remote_id will be set automatically
book.remote_id = None
book.save()
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0010_importjob_retry"),
]
operations = [
migrations.AddField(
model_name="author",
name="origin_id",
field=models.CharField(max_length=255, null=True),
),
migrations.AddField(
model_name="book",
name="origin_id",
field=models.CharField(max_length=255, null=True),
),
migrations.RunPython(set_origin_id),
]