Keep group as a foreign key field
This commit is contained in:
parent
9948dd2356
commit
801ba03aaf
2 changed files with 2 additions and 28 deletions
|
@ -16,13 +16,6 @@ class Migration(migrations.Migration):
|
||||||
model_name="notification",
|
model_name="notification",
|
||||||
name="related_book",
|
name="related_book",
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
|
||||||
model_name="notification",
|
|
||||||
name="related_groups",
|
|
||||||
field=models.ManyToManyField(
|
|
||||||
related_name="notifications", to="bookwyrm.Group"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name="notification",
|
model_name="notification",
|
||||||
name="related_list_items",
|
name="related_list_items",
|
||||||
|
@ -42,16 +35,6 @@ class Migration(migrations.Migration):
|
||||||
related_name="notifications", to=settings.AUTH_USER_MODEL
|
related_name="notifications", to=settings.AUTH_USER_MODEL
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
|
||||||
model_name="notification",
|
|
||||||
name="related_group",
|
|
||||||
field=models.ForeignKey(
|
|
||||||
null=True,
|
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
|
||||||
related_name="notifications_temp",
|
|
||||||
to="bookwyrm.group",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name="notification",
|
model_name="notification",
|
||||||
name="related_list_item",
|
name="related_list_item",
|
||||||
|
@ -79,11 +62,6 @@ class Migration(migrations.Migration):
|
||||||
FROM bookwyrm_notification
|
FROM bookwyrm_notification
|
||||||
WHERE bookwyrm_notification.related_user_id IS NOT NULL;
|
WHERE bookwyrm_notification.related_user_id IS NOT NULL;
|
||||||
|
|
||||||
INSERT INTO bookwyrm_notification_related_groups (notification_id, group_id)
|
|
||||||
SELECT id, related_group_id
|
|
||||||
FROM bookwyrm_notification
|
|
||||||
WHERE bookwyrm_notification.related_group_id IS NOT NULL;
|
|
||||||
|
|
||||||
INSERT INTO bookwyrm_notification_related_list_items (notification_id, listitem_id)
|
INSERT INTO bookwyrm_notification_related_list_items (notification_id, listitem_id)
|
||||||
SELECT id, related_list_item_id
|
SELECT id, related_list_item_id
|
||||||
FROM bookwyrm_notification
|
FROM bookwyrm_notification
|
||||||
|
@ -97,10 +75,6 @@ class Migration(migrations.Migration):
|
||||||
""",
|
""",
|
||||||
reverse_sql=migrations.RunSQL.noop,
|
reverse_sql=migrations.RunSQL.noop,
|
||||||
),
|
),
|
||||||
migrations.RemoveField(
|
|
||||||
model_name="notification",
|
|
||||||
name="related_group",
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name="notification",
|
model_name="notification",
|
||||||
name="related_list_item",
|
name="related_list_item",
|
||||||
|
|
|
@ -43,8 +43,8 @@ class Notification(BookWyrmModel):
|
||||||
related_users = models.ManyToManyField(
|
related_users = models.ManyToManyField(
|
||||||
"User", symmetrical=False, related_name="notifications"
|
"User", symmetrical=False, related_name="notifications"
|
||||||
)
|
)
|
||||||
related_groups = models.ManyToManyField(
|
related_group = models.ForeignKey(
|
||||||
"Group", symmetrical=False, related_name="notifications"
|
"Group", on_delete=models.CASCADE, null=True, related_name="notifications"
|
||||||
)
|
)
|
||||||
related_status = models.ForeignKey("Status", on_delete=models.CASCADE, null=True)
|
related_status = models.ForeignKey("Status", on_delete=models.CASCADE, null=True)
|
||||||
related_import = models.ForeignKey("ImportJob", on_delete=models.CASCADE, null=True)
|
related_import = models.ForeignKey("ImportJob", on_delete=models.CASCADE, null=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue