From c74f125b7cb58921da52804f2b9deb0da6740af8 Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Thu, 1 Jun 2017 13:44:51 +0500 Subject: [PATCH] analytics: Add on_delete in foreign keys. on_delete will be a required arg for ForeignKey in Django 2.0. Set it to models.CASCADE on models and in existing migrations if you want to maintain the current default behavior. See https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.on_delete --- analytics/migrations/0001_initial.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/analytics/migrations/0001_initial.py b/analytics/migrations/0001_initial.py index 0329afe3e1..0e037375e3 100644 --- a/analytics/migrations/0001_initial.py +++ b/analytics/migrations/0001_initial.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from django.db import models, migrations +import django.db.models.deletion from django.conf import settings import zerver.lib.str_utils @@ -26,13 +27,13 @@ class Migration(migrations.Migration): name='HuddleCount', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('huddle', models.ForeignKey(to='zerver.Recipient')), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ('huddle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Recipient')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('property', models.CharField(max_length=40)), ('end_time', models.DateTimeField()), ('interval', models.CharField(max_length=20)), ('value', models.BigIntegerField()), - ('anomaly', models.ForeignKey(to='analytics.Anomaly', null=True)), + ('anomaly', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Anomaly', null=True)), ], bases=(zerver.lib.str_utils.ModelReprMixin, models.Model), ), @@ -44,7 +45,7 @@ class Migration(migrations.Migration): ('end_time', models.DateTimeField()), ('interval', models.CharField(max_length=20)), ('value', models.BigIntegerField()), - ('anomaly', models.ForeignKey(to='analytics.Anomaly', null=True)), + ('anomaly', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Anomaly', null=True)), ], bases=(zerver.lib.str_utils.ModelReprMixin, models.Model), ), @@ -52,12 +53,12 @@ class Migration(migrations.Migration): name='RealmCount', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('realm', models.ForeignKey(to='zerver.Realm')), + ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')), ('property', models.CharField(max_length=40)), ('end_time', models.DateTimeField()), ('interval', models.CharField(max_length=20)), ('value', models.BigIntegerField()), - ('anomaly', models.ForeignKey(to='analytics.Anomaly', null=True)), + ('anomaly', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Anomaly', null=True)), ], bases=(zerver.lib.str_utils.ModelReprMixin, models.Model), @@ -66,13 +67,13 @@ class Migration(migrations.Migration): name='StreamCount', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('realm', models.ForeignKey(to='zerver.Realm')), - ('stream', models.ForeignKey(to='zerver.Stream')), + ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')), + ('stream', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Stream')), ('property', models.CharField(max_length=40)), ('end_time', models.DateTimeField()), ('interval', models.CharField(max_length=20)), ('value', models.BigIntegerField()), - ('anomaly', models.ForeignKey(to='analytics.Anomaly', null=True)), + ('anomaly', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Anomaly', null=True)), ], bases=(zerver.lib.str_utils.ModelReprMixin, models.Model), ), @@ -80,13 +81,13 @@ class Migration(migrations.Migration): name='UserCount', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('realm', models.ForeignKey(to='zerver.Realm')), - ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ('realm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('property', models.CharField(max_length=40)), ('end_time', models.DateTimeField()), ('interval', models.CharField(max_length=20)), ('value', models.BigIntegerField()), - ('anomaly', models.ForeignKey(to='analytics.Anomaly', null=True)), + ('anomaly', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.Anomaly', null=True)), ], bases=(zerver.lib.str_utils.ModelReprMixin, models.Model), ),