perf: remove notification migrations

pull/13646/head
ibuler 2024-07-09 11:22:04 +08:00 committed by 老广
parent c56ab9bc1e
commit 75fa96b29c
3 changed files with 16 additions and 25 deletions

View File

@ -1551,7 +1551,7 @@ msgstr "未知"
#: assets/const/automation.py:7
msgid "OK"
msgstr ""
msgstr "成功"
#: assets/const/automation.py:12
msgid "Ping"

View File

@ -6,6 +6,20 @@ from django.db import migrations, models
import django.db.models.deletion
def init_user_msg_subscription(apps, schema_editor):
User = apps.get_model('users', 'User')
UserMsgSubscription = apps.get_model('notifications', 'UserMsgSubscription')
receive_backends = ['site_msg', 'email']
user = User.objects.filter(username='admin').first()
if not user:
return
UserMsgSubscription.objects.update_or_create(
defaults={'receive_backends': receive_backends}, user=user
)
class Migration(migrations.Migration):
initial = True
@ -57,4 +71,5 @@ class Migration(migrations.Migration):
name='users',
field=models.ManyToManyField(related_name='recv_site_messages', through='notifications.SiteMessage', to=settings.AUTH_USER_MODEL),
),
migrations.RunPython(init_user_msg_subscription)
]

View File

@ -1,24 +0,0 @@
# Generated by Django 4.1.13 on 2024-05-21 11:04
from django.db import migrations
def init_user_msg_subscription(apps, schema_editor):
User = apps.get_model('users', 'User')
UserMsgSubscription = apps.get_model('notifications', 'UserMsgSubscription')
receive_backends = ['site_msg', 'email']
user = User.objects.get(username='admin')
UserMsgSubscription.objects.update_or_create(
defaults={'receive_backends': receive_backends}, user=user
)
class Migration(migrations.Migration):
dependencies = [
('notifications', '0002_auto_20210909_1946'),
]
operations = [
migrations.RunPython(init_user_msg_subscription),
]