2020-11-30 18:32:54 +00:00
|
|
|
# Generated by Django 3.0.7 on 2020-11-30 19:39
|
|
|
|
|
|
|
|
import bookwyrm.models.fields
|
|
|
|
from django.db import migrations
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-12-03 20:35:57 +00:00
|
|
|
def update_notnull(app_registry, schema_editor):
|
|
|
|
db_alias = schema_editor.connection.alias
|
2021-03-08 16:49:10 +00:00
|
|
|
users = app_registry.get_model("bookwyrm", "User")
|
2020-12-03 20:35:57 +00:00
|
|
|
for user in users.objects.using(db_alias):
|
|
|
|
if user.name and user.summary:
|
|
|
|
continue
|
|
|
|
if not user.summary:
|
2021-03-08 16:49:10 +00:00
|
|
|
user.summary = ""
|
2020-12-03 20:35:57 +00:00
|
|
|
if not user.name:
|
2021-03-08 16:49:10 +00:00
|
|
|
user.name = ""
|
2020-12-03 20:35:57 +00:00
|
|
|
user.save()
|
2020-11-30 18:32:54 +00:00
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-11-30 18:32:54 +00:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-03-08 16:49:10 +00:00
|
|
|
("bookwyrm", "0018_auto_20201130_1832"),
|
2020-11-30 18:32:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2020-12-03 20:35:57 +00:00
|
|
|
migrations.RunPython(update_notnull),
|
2020-11-30 18:32:54 +00:00
|
|
|
migrations.AlterField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="user",
|
|
|
|
name="name",
|
|
|
|
field=bookwyrm.models.fields.CharField(default="", max_length=100),
|
2020-11-30 18:32:54 +00:00
|
|
|
),
|
|
|
|
migrations.AlterField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="user",
|
|
|
|
name="summary",
|
|
|
|
field=bookwyrm.models.fields.TextField(default=""),
|
2020-11-30 18:32:54 +00:00
|
|
|
),
|
|
|
|
]
|