From bbc78f03aed8b42bc9aa8a8d64850740c6d2d548 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 14 Nov 2023 07:21:27 +1100 Subject: [PATCH] fix DB migrations (#3111) fix migrations and linting --- .../migrations/0182_merge_20230905_2240.py | 13 --- .../migrations/0183_auto_20231021_2050.py | 85 ------------------- ...184_sitesettings_user_import_time_limit.py | 18 ---- ...arentjob.py => 0185_auto_20231113_2011.py} | 51 ++++++++++- .../migrations/0185_merge_20231105_1453.py | 13 --- ...86_alter_notification_notification_type.py | 43 ---------- bookwyrm/models/notification.py | 1 - 7 files changed, 49 insertions(+), 175 deletions(-) delete mode 100644 bookwyrm/migrations/0182_merge_20230905_2240.py delete mode 100644 bookwyrm/migrations/0183_auto_20231021_2050.py delete mode 100644 bookwyrm/migrations/0184_sitesettings_user_import_time_limit.py rename bookwyrm/migrations/{0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob.py => 0185_auto_20231113_2011.py} (74%) delete mode 100644 bookwyrm/migrations/0185_merge_20231105_1453.py delete mode 100644 bookwyrm/migrations/0186_alter_notification_notification_type.py diff --git a/bookwyrm/migrations/0182_merge_20230905_2240.py b/bookwyrm/migrations/0182_merge_20230905_2240.py deleted file mode 100644 index 83920a9c7..000000000 --- a/bookwyrm/migrations/0182_merge_20230905_2240.py +++ /dev/null @@ -1,13 +0,0 @@ -# Generated by Django 3.2.19 on 2023-09-05 22:40 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("bookwyrm", "0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob"), - ("bookwyrm", "0181_merge_20230806_2302"), - ] - - operations = [] diff --git a/bookwyrm/migrations/0183_auto_20231021_2050.py b/bookwyrm/migrations/0183_auto_20231021_2050.py deleted file mode 100644 index c960fe5bd..000000000 --- a/bookwyrm/migrations/0183_auto_20231021_2050.py +++ /dev/null @@ -1,85 +0,0 @@ -# Generated by Django 3.2.20 on 2023-10-21 20:50 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ("bookwyrm", "0182_merge_20230905_2240"), - ] - - operations = [ - migrations.AddField( - model_name="notification", - name="related_user_export", - field=models.ForeignKey( - null=True, - on_delete=django.db.models.deletion.CASCADE, - to="bookwyrm.bookwyrmexportjob", - ), - ), - migrations.AlterField( - model_name="childjob", - name="status", - field=models.CharField( - choices=[ - ("pending", "Pending"), - ("active", "Active"), - ("complete", "Complete"), - ("stopped", "Stopped"), - ("failed", "Failed"), - ], - default="pending", - max_length=50, - null=True, - ), - ), - migrations.AlterField( - model_name="notification", - name="notification_type", - field=models.CharField( - choices=[ - ("FAVORITE", "Favorite"), - ("REPLY", "Reply"), - ("MENTION", "Mention"), - ("TAG", "Tag"), - ("FOLLOW", "Follow"), - ("FOLLOW_REQUEST", "Follow Request"), - ("BOOST", "Boost"), - ("IMPORT", "Import"), - ("USER_IMPORT", "User Import"), - ("USER_EXPORT", "User Export"), - ("ADD", "Add"), - ("REPORT", "Report"), - ("LINK_DOMAIN", "Link Domain"), - ("INVITE", "Invite"), - ("ACCEPT", "Accept"), - ("JOIN", "Join"), - ("LEAVE", "Leave"), - ("REMOVE", "Remove"), - ("GROUP_PRIVACY", "Group Privacy"), - ("GROUP_NAME", "Group Name"), - ("GROUP_DESCRIPTION", "Group Description"), - ], - max_length=255, - ), - ), - migrations.AlterField( - model_name="parentjob", - name="status", - field=models.CharField( - choices=[ - ("pending", "Pending"), - ("active", "Active"), - ("complete", "Complete"), - ("stopped", "Stopped"), - ("failed", "Failed"), - ], - default="pending", - max_length=50, - null=True, - ), - ), - ] diff --git a/bookwyrm/migrations/0184_sitesettings_user_import_time_limit.py b/bookwyrm/migrations/0184_sitesettings_user_import_time_limit.py deleted file mode 100644 index 24b4dad37..000000000 --- a/bookwyrm/migrations/0184_sitesettings_user_import_time_limit.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.20 on 2023-10-22 02:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("bookwyrm", "0183_auto_20231021_2050"), - ] - - operations = [ - migrations.AddField( - model_name="sitesettings", - name="user_import_time_limit", - field=models.IntegerField(default=48), - ), - ] diff --git a/bookwyrm/migrations/0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob.py b/bookwyrm/migrations/0185_auto_20231113_2011.py similarity index 74% rename from bookwyrm/migrations/0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob.py rename to bookwyrm/migrations/0185_auto_20231113_2011.py index d13668cc4..d1a61d6d4 100644 --- a/bookwyrm/migrations/0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob.py +++ b/bookwyrm/migrations/0185_auto_20231113_2011.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.19 on 2023-08-31 22:57 +# Generated by Django 3.2.23 on 2023-11-13 20:11 from django.conf import settings import django.contrib.postgres.fields @@ -10,7 +10,7 @@ import django.utils.timezone class Migration(migrations.Migration): dependencies = [ - ("bookwyrm", "0178_auto_20230328_2132"), + ("bookwyrm", "0184_auto_20231106_0421"), ] operations = [ @@ -44,6 +44,7 @@ class Migration(migrations.Migration): ("active", "Active"), ("complete", "Complete"), ("stopped", "Stopped"), + ("failed", "Failed"), ], default="pending", max_length=50, @@ -62,6 +63,42 @@ class Migration(migrations.Migration): "abstract": False, }, ), + migrations.AddField( + model_name="sitesettings", + name="user_import_time_limit", + field=models.IntegerField(default=48), + ), + migrations.AlterField( + model_name="notification", + name="notification_type", + field=models.CharField( + choices=[ + ("FAVORITE", "Favorite"), + ("BOOST", "Boost"), + ("REPLY", "Reply"), + ("MENTION", "Mention"), + ("TAG", "Tag"), + ("FOLLOW", "Follow"), + ("FOLLOW_REQUEST", "Follow Request"), + ("IMPORT", "Import"), + ("USER_IMPORT", "User Import"), + ("USER_EXPORT", "User Export"), + ("ADD", "Add"), + ("REPORT", "Report"), + ("LINK_DOMAIN", "Link Domain"), + ("INVITE", "Invite"), + ("ACCEPT", "Accept"), + ("JOIN", "Join"), + ("LEAVE", "Leave"), + ("REMOVE", "Remove"), + ("GROUP_PRIVACY", "Group Privacy"), + ("GROUP_NAME", "Group Name"), + ("GROUP_DESCRIPTION", "Group Description"), + ("MOVE", "Move"), + ], + max_length=255, + ), + ), migrations.CreateModel( name="BookwyrmExportJob", fields=[ @@ -143,6 +180,7 @@ class Migration(migrations.Migration): ("active", "Active"), ("complete", "Complete"), ("stopped", "Stopped"), + ("failed", "Failed"), ], default="pending", max_length=50, @@ -162,4 +200,13 @@ class Migration(migrations.Migration): "abstract": False, }, ), + migrations.AddField( + model_name="notification", + name="related_user_export", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="bookwyrm.bookwyrmexportjob", + ), + ), ] diff --git a/bookwyrm/migrations/0185_merge_20231105_1453.py b/bookwyrm/migrations/0185_merge_20231105_1453.py deleted file mode 100644 index 767fe4195..000000000 --- a/bookwyrm/migrations/0185_merge_20231105_1453.py +++ /dev/null @@ -1,13 +0,0 @@ -# Generated by Django 3.2.20 on 2023-11-05 14:53 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("bookwyrm", "0182_auto_20231027_1122"), - ("bookwyrm", "0184_sitesettings_user_import_time_limit"), - ] - - operations = [] diff --git a/bookwyrm/migrations/0186_alter_notification_notification_type.py b/bookwyrm/migrations/0186_alter_notification_notification_type.py deleted file mode 100644 index 3e4effdfa..000000000 --- a/bookwyrm/migrations/0186_alter_notification_notification_type.py +++ /dev/null @@ -1,43 +0,0 @@ -# Generated by Django 3.2.20 on 2023-11-05 14:55 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("bookwyrm", "0185_merge_20231105_1453"), - ] - - operations = [ - migrations.AlterField( - model_name="notification", - name="notification_type", - field=models.CharField( - choices=[ - ("FAVORITE", "Favorite"), - ("REPLY", "Reply"), - ("MENTION", "Mention"), - ("TAG", "Tag"), - ("FOLLOW", "Follow"), - ("FOLLOW_REQUEST", "Follow Request"), - ("BOOST", "Boost"), - ("IMPORT", "Import"), - ("USER_IMPORT", "User Import"), - ("USER_EXPORT", "User Export"), - ("ADD", "Add"), - ("REPORT", "Report"), - ("LINK_DOMAIN", "Link Domain"), - ("INVITE", "Invite"), - ("ACCEPT", "Accept"), - ("JOIN", "Join"), - ("LEAVE", "Leave"), - ("REMOVE", "Remove"), - ("GROUP_PRIVACY", "Group Privacy"), - ("GROUP_NAME", "Group Name"), - ("GROUP_DESCRIPTION", "Group Description"), - ("MOVE", "Move"), - ], - max_length=255, - ), - ), - ] diff --git a/bookwyrm/models/notification.py b/bookwyrm/models/notification.py index d4774cf54..70aeec82a 100644 --- a/bookwyrm/models/notification.py +++ b/bookwyrm/models/notification.py @@ -57,7 +57,6 @@ class NotificationType(models.TextChoices): class Notification(BookWyrmModel): """a notification object""" - user = models.ForeignKey("User", on_delete=models.CASCADE) read = models.BooleanField(default=False) notification_type = models.CharField(