moviewyrm/bookwyrm/migrations/0011_auto_20201113_1727.py

35 lines
944 B
Python
Raw Permalink Normal View History

2020-11-13 17:47:35 +00:00
# Generated by Django 3.0.7 on 2020-11-13 17:27
from django.db import migrations, models
2021-03-08 16:49:10 +00:00
2020-11-13 17:47:35 +00:00
def set_origin_id(app_registry, schema_editor):
db_alias = schema_editor.connection.alias
2021-03-08 16:49:10 +00:00
books = app_registry.get_model("bookwyrm", "Book").objects.using(db_alias)
2020-11-13 17:47:35 +00:00
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 = [
2021-03-08 16:49:10 +00:00
("bookwyrm", "0010_importjob_retry"),
2020-11-13 17:47:35 +00:00
]
operations = [
migrations.AddField(
2021-03-08 16:49:10 +00:00
model_name="author",
name="origin_id",
2020-11-13 17:47:35 +00:00
field=models.CharField(max_length=255, null=True),
),
migrations.AddField(
2021-03-08 16:49:10 +00:00
model_name="book",
name="origin_id",
2020-11-13 17:47:35 +00:00
field=models.CharField(max_length=255, null=True),
),
migrations.RunPython(set_origin_id),
]