From 9d9177ed05cbefe7cd22e4d4b95f7b9d05e9deb9 Mon Sep 17 00:00:00 2001 From: xinwen Date: Mon, 2 Nov 2020 16:56:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor(terminal):=20=E5=8E=BB=E6=8E=89=20Sess?= =?UTF-8?q?ion=20=E4=B8=AD=20Terminal=20=E7=9A=84=E5=A4=96=E9=94=AE?= =?UTF-8?q?=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0027_auto_20201102_1651.py | 19 +++++++++++++++++++ apps/terminal/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 apps/terminal/migrations/0027_auto_20201102_1651.py diff --git a/apps/terminal/migrations/0027_auto_20201102_1651.py b/apps/terminal/migrations/0027_auto_20201102_1651.py new file mode 100644 index 000000000..5a328d84a --- /dev/null +++ b/apps/terminal/migrations/0027_auto_20201102_1651.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.13 on 2020-11-02 08:51 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('terminal', '0026_auto_20201027_1905'), + ] + + operations = [ + migrations.AlterField( + model_name='session', + name='terminal', + field=models.ForeignKey(db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='terminal.Terminal'), + ), + ] diff --git a/apps/terminal/models.py b/apps/terminal/models.py index a0f074b48..17c40e54b 100644 --- a/apps/terminal/models.py +++ b/apps/terminal/models.py @@ -198,7 +198,7 @@ class Session(OrgModelMixin): is_finished = models.BooleanField(default=False, db_index=True) has_replay = models.BooleanField(default=False, verbose_name=_("Replay")) has_command = models.BooleanField(default=False, verbose_name=_("Command")) - terminal = models.ForeignKey(Terminal, null=True, on_delete=models.SET_NULL) + terminal = models.ForeignKey(Terminal, null=True, on_delete=models.DO_NOTHING, db_constraint=False) protocol = models.CharField(choices=PROTOCOL.choices, default='ssh', max_length=16, db_index=True) date_start = models.DateTimeField(verbose_name=_("Date start"), db_index=True, default=timezone.now) date_end = models.DateTimeField(verbose_name=_("Date end"), null=True)