2021-01-18 19:57:20 +00:00
|
|
|
# Generated by Django 3.0.7 on 2021-01-18 19:54
|
2021-01-18 19:01:06 +00:00
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2021-01-25 00:39:26 +00:00
|
|
|
def empty_to_null(apps, schema_editor):
|
|
|
|
User = apps.get_model("bookwyrm", "User")
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
User.objects.using(db_alias).filter(email="").update(email=None)
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2021-01-25 00:39:26 +00:00
|
|
|
def null_to_empty(apps, schema_editor):
|
|
|
|
User = apps.get_model("bookwyrm", "User")
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
User.objects.using(db_alias).filter(email=None).update(email="")
|
2021-01-18 19:01:06 +00:00
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2021-01-18 19:01:06 +00:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-03-08 16:49:10 +00:00
|
|
|
("bookwyrm", "0036_annualgoal"),
|
2021-01-18 19:01:06 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AlterModelOptions(
|
2021-03-08 16:49:10 +00:00
|
|
|
name="shelfbook",
|
|
|
|
options={"ordering": ("-created_date",)},
|
2021-01-18 19:01:06 +00:00
|
|
|
),
|
2021-01-25 00:39:26 +00:00
|
|
|
migrations.AlterField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="user",
|
|
|
|
name="email",
|
2021-01-25 00:39:26 +00:00
|
|
|
field=models.EmailField(max_length=254, null=True),
|
|
|
|
),
|
|
|
|
migrations.RunPython(empty_to_null, null_to_empty),
|
2021-01-18 19:01:06 +00:00
|
|
|
migrations.AlterField(
|
2021-03-08 16:49:10 +00:00
|
|
|
model_name="user",
|
|
|
|
name="email",
|
2021-01-18 19:57:20 +00:00
|
|
|
field=models.EmailField(max_length=254, null=True, unique=True),
|
2021-01-18 19:01:06 +00:00
|
|
|
),
|
|
|
|
]
|