fixes import matching with local books
This commit is contained in:
33
bookwyrm/migrations/0011_auto_20201113_1727.py
Normal file
33
bookwyrm/migrations/0011_auto_20201113_1727.py
Normal file
@ -0,0 +1,33 @@
|
||||
# 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),
|
||||
]
|
Reference in New Issue
Block a user