diff --git a/apps/proxy/migrations/0005_auto_20210506_1950.py b/apps/proxy/migrations/0005_auto_20210506_1950.py index fdf0a28123..be9eec1e1d 100644 --- a/apps/proxy/migrations/0005_auto_20210506_1950.py +++ b/apps/proxy/migrations/0005_auto_20210506_1950.py @@ -38,7 +38,7 @@ class Migration(migrations.Migration): model_name="usertrafficlog", name="proxy_node", field=models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, + on_delete=django.db.models.deletion.DO_NOTHING, to="proxy.proxynode", verbose_name="代理节点", ), @@ -48,7 +48,7 @@ class Migration(migrations.Migration): name="user", field=models.ForeignKey( null=True, - on_delete=django.db.models.deletion.CASCADE, + on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL, verbose_name="用户", ), diff --git a/apps/proxy/migrations/0021_alter_usertrafficlog_proxy_node_and_more.py b/apps/proxy/migrations/0021_alter_usertrafficlog_proxy_node_and_more.py new file mode 100644 index 0000000000..497d2b0f3a --- /dev/null +++ b/apps/proxy/migrations/0021_alter_usertrafficlog_proxy_node_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.6 on 2023-12-17 03:29 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("proxy", "0020_alter_proxynode_ehco_reload_interval"), + ] + + operations = [ + migrations.AlterField( + model_name="usertrafficlog", + name="proxy_node", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="proxy.proxynode", + verbose_name="代理节点", + ), + ), + migrations.AlterField( + model_name="usertrafficlog", + name="user", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + verbose_name="用户", + ), + ), + ] diff --git a/apps/proxy/models.py b/apps/proxy/models.py index 2d3bcbbead..77370dedf6 100644 --- a/apps/proxy/models.py +++ b/apps/proxy/models.py @@ -712,11 +712,11 @@ def remark(self): class UserTrafficLog(BaseLogModel): user = models.ForeignKey( - User, on_delete=models.DO_NOTHING, verbose_name="用户", null=True + User, on_delete=models.CASCADE, verbose_name="用户", null=True ) proxy_node = models.ForeignKey( ProxyNode, - on_delete=models.DO_NOTHING, + on_delete=models.CASCADE, verbose_name="代理节点", ) upload_traffic = models.BigIntegerField("上传流量", default=0)