2021-08-28 17:33:57 +00:00
|
|
|
# Generated by Django 3.2.4 on 2021-08-28 17:24
|
|
|
|
|
|
|
|
import bookwyrm.models.fields
|
|
|
|
from django.conf import settings
|
|
|
|
from django.db import migrations, models
|
2021-08-28 17:41:16 +00:00
|
|
|
from django.db.models import F, Value, CharField
|
|
|
|
from django.db.models.functions import Concat
|
|
|
|
|
|
|
|
|
|
|
|
def forwards_func(apps, schema_editor):
|
|
|
|
"""generate followers url"""
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
apps.get_model("bookwyrm", "User").objects.using(db_alias).annotate(
|
|
|
|
generated_url=Concat(
|
|
|
|
F("remote_id"), Value("/followers"), output_field=CharField()
|
|
|
|
)
|
|
|
|
).update(followers_url=models.F("generated_url"))
|
|
|
|
|
|
|
|
|
|
|
|
def reverse_func(apps, schema_editor):
|
|
|
|
"""noop"""
|
2021-08-28 17:33:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-08-28 17:41:16 +00:00
|
|
|
("bookwyrm", "0085_user_saved_lists"),
|
2021-08-28 17:33:57 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
2021-08-28 17:41:16 +00:00
|
|
|
model_name="user",
|
|
|
|
name="followers_url",
|
|
|
|
field=bookwyrm.models.fields.CharField(
|
|
|
|
default="/followers", max_length=255
|
|
|
|
),
|
2021-08-28 17:33:57 +00:00
|
|
|
preserve_default=False,
|
|
|
|
),
|
2021-08-28 17:41:16 +00:00
|
|
|
migrations.RunPython(forwards_func, reverse_func),
|
2021-08-28 17:33:57 +00:00
|
|
|
migrations.AlterField(
|
2021-08-28 17:41:16 +00:00
|
|
|
model_name="user",
|
|
|
|
name="followers",
|
|
|
|
field=models.ManyToManyField(
|
|
|
|
related_name="following",
|
|
|
|
through="bookwyrm.UserFollows",
|
|
|
|
to=settings.AUTH_USER_MODEL,
|
|
|
|
),
|
2021-08-28 17:33:57 +00:00
|
|
|
),
|
|
|
|
]
|