fixes import matching with local books
This commit is contained in:
parent
e3a803b907
commit
86504989b4
11 changed files with 63 additions and 50 deletions
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),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue