Use name field only for author name
It feels janky to remove a more granular name designation, but all these first/last name fields were algorithmically populated by a dubious process of splitting the name by a space character. If it makes sense to have first/last name fields, it should be re-added with some consideration.
This commit is contained in:
30
bookwyrm/migrations/0022_auto_20201212_1744.py
Normal file
30
bookwyrm/migrations/0022_auto_20201212_1744.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 3.0.7 on 2020-12-12 17:44
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def set_author_name(app_registry, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
authors = app_registry.get_model('bookwyrm', 'Author')
|
||||
for author in authors.objects.using(db_alias):
|
||||
if not author.name:
|
||||
author.name = '%s %s' % (author.first_name, author.last_name)
|
||||
author.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bookwyrm', '0021_merge_20201212_1737'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(set_author_name),
|
||||
migrations.RemoveField(
|
||||
model_name='author',
|
||||
name='first_name',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='author',
|
||||
name='last_name',
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user