2020-12-12 17:47:27 +00:00
|
|
|
# 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
|
2021-03-08 16:49:10 +00:00
|
|
|
authors = app_registry.get_model("bookwyrm", "Author")
|
2020-12-12 17:47:27 +00:00
|
|
|
for author in authors.objects.using(db_alias):
|
|
|
|
if not author.name:
|
2021-03-08 16:49:10 +00:00
|
|
|
author.name = "%s %s" % (author.first_name, author.last_name)
|
2020-12-12 17:47:27 +00:00
|
|
|
author.save()
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-12-12 17:47:27 +00:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-03-08 16:49:10 +00:00
|
|
|
("bookwyrm", "0021_merge_20201212_1737"),
|
2020-12-12 17:47:27 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(set_author_name),
|
|
|
|
migrations.RemoveField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="author",
|
|
|
|
name="first_name",
|
2020-12-12 17:47:27 +00:00
|
|
|
),
|
|
|
|
migrations.RemoveField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="author",
|
|
|
|
name="last_name",
|
2020-12-12 17:47:27 +00:00
|
|
|
),
|
|
|
|
]
|