mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-28 11:00:36 +00:00
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
# 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
|
|
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"""
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("bookwyrm", "0085_user_saved_lists"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="user",
|
|
name="followers_url",
|
|
field=bookwyrm.models.fields.CharField(
|
|
default="/followers", max_length=255
|
|
),
|
|
preserve_default=False,
|
|
),
|
|
migrations.RunPython(forwards_func, reverse_func),
|
|
migrations.AlterField(
|
|
model_name="user",
|
|
name="followers",
|
|
field=models.ManyToManyField(
|
|
related_name="following",
|
|
through="bookwyrm.UserFollows",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
]
|