From 7db8d91435f9b00b2729d8fea171b2b204debab1 Mon Sep 17 00:00:00 2001 From: Gao Jiangmiao Date: Mon, 19 Aug 2019 09:12:19 +0800 Subject: [PATCH] Fix on_delete of ForeignKey and OneToOneField for migrations --- accounts/migrations/0001_initial.py | 5 ++--- accounts/migrations/0003_usersshkey.py | 3 +-- accounts/migrations/0004_userattributes.py | 3 +-- accounts/migrations/0015_auto_20180808_1449.py | 3 +-- instances/migrations/0001_initial.py | 2 +- logs/migrations/0001_initial.py | 4 ++-- logs/migrations/0002_auto_20150316_1420.py | 2 +- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py index 0431499..6e0f4a6 100644 --- a/accounts/migrations/0001_initial.py +++ b/accounts/migrations/0001_initial.py @@ -1,6 +1,5 @@ from django.db import models, migrations from django.conf import settings -from django.db.models import CASCADE class Migration(migrations.Migration): @@ -17,8 +16,8 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('is_change', models.BooleanField(default=False)), ('is_delete', models.BooleanField(default=False)), - ('instance', models.ForeignKey(to='instances.Instance', on_delete=CASCADE)), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=CASCADE)), + ('instance', models.ForeignKey(to='instances.Instance', on_delete=models.CASCADE)), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ }, diff --git a/accounts/migrations/0003_usersshkey.py b/accounts/migrations/0003_usersshkey.py index 1a21de6..fe7d147 100644 --- a/accounts/migrations/0003_usersshkey.py +++ b/accounts/migrations/0003_usersshkey.py @@ -1,6 +1,5 @@ from django.db import models, migrations from django.conf import settings -from django.db.models import CASCADE class Migration(migrations.Migration): @@ -17,7 +16,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('keyname', models.CharField(max_length=25)), ('keypublic', models.CharField(max_length=500)), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=CASCADE)), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], ), ] diff --git a/accounts/migrations/0004_userattributes.py b/accounts/migrations/0004_userattributes.py index 021857b..bd41852 100644 --- a/accounts/migrations/0004_userattributes.py +++ b/accounts/migrations/0004_userattributes.py @@ -1,6 +1,5 @@ from django.db import models, migrations from django.conf import settings -from django.db.models import CASCADE class Migration(migrations.Migration): @@ -18,7 +17,7 @@ class Migration(migrations.Migration): ('max_instances', models.IntegerField(default=0)), ('max_cpus', models.IntegerField(default=0)), ('max_memory', models.IntegerField(default=0)), - ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=CASCADE)), + ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], ), ] diff --git a/accounts/migrations/0015_auto_20180808_1449.py b/accounts/migrations/0015_auto_20180808_1449.py index 2bb88fe..3e5541e 100644 --- a/accounts/migrations/0015_auto_20180808_1449.py +++ b/accounts/migrations/0015_auto_20180808_1449.py @@ -1,6 +1,5 @@ from django.conf import settings from django.db import migrations, models -from django.db.models import DO_NOTHING class Migration(migrations.Migration): @@ -13,6 +12,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='usersshkey', name='user', - field=models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=DO_NOTHING), + field=models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING), ), ] diff --git a/instances/migrations/0001_initial.py b/instances/migrations/0001_initial.py index d3c6bc1..963488d 100644 --- a/instances/migrations/0001_initial.py +++ b/instances/migrations/0001_initial.py @@ -14,7 +14,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=20)), ('uuid', models.CharField(max_length=36)), - ('compute', models.ForeignKey(to='computes.Compute')), + ('compute', models.ForeignKey(to='computes.Compute', on_delete=models.CASCADE)), ], options={ }, diff --git a/logs/migrations/0001_initial.py b/logs/migrations/0001_initial.py index 5913b41..f0ac5d9 100644 --- a/logs/migrations/0001_initial.py +++ b/logs/migrations/0001_initial.py @@ -16,8 +16,8 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('message', models.CharField(max_length=255)), ('date', models.DateTimeField(auto_now=True)), - ('instance', models.ForeignKey(to='instances.Instance')), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ('instance', models.ForeignKey(to='instances.Instance', on_delete=models.CASCADE)), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ }, diff --git a/logs/migrations/0002_auto_20150316_1420.py b/logs/migrations/0002_auto_20150316_1420.py index 0a027bb..db67f3f 100644 --- a/logs/migrations/0002_auto_20150316_1420.py +++ b/logs/migrations/0002_auto_20150316_1420.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='logs', name='user', - field=models.ForeignKey(to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=False, ), migrations.AlterField(