Set on_delete=models.CASCADE on all ForeignKey fields
authorMagnus Hagander <magnus@hagander.net>
Tue, 31 Mar 2020 20:33:51 +0000 (22:33 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 31 Mar 2020 20:34:51 +0000 (22:34 +0200)
This is the bardware compatible value that will be needed once we
upgrade django later.

28 files changed:
pgweb/account/migrations/0001_initial.py
pgweb/account/models.py
pgweb/contributors/migrations/0001_initial.py
pgweb/contributors/models.py
pgweb/core/migrations/0001_initial.py
pgweb/core/models.py
pgweb/docs/migrations/0001_initial.py
pgweb/docs/models.py
pgweb/downloads/migrations/0001_initial.py
pgweb/downloads/models.py
pgweb/events/migrations/0001_initial.py
pgweb/events/models.py
pgweb/featurematrix/migrations/0001_initial.py
pgweb/featurematrix/models.py
pgweb/lists/migrations/0001_initial.py
pgweb/lists/models.py
pgweb/news/migrations/0001_initial.py
pgweb/news/models.py
pgweb/profserv/migrations/0001_initial.py
pgweb/profserv/models.py
pgweb/pugs/migrations/0001_initial.py
pgweb/pugs/models.py
pgweb/security/migrations/0001_initial.py
pgweb/security/models.py
pgweb/sponsors/migrations/0001_initial.py
pgweb/sponsors/models.py
pgweb/survey/migrations/0001_initial.py
pgweb/survey/models.py

index 066127b5674bb636850268d6d48eedf87c984fcc..0a7db8393123cee45ea2a7df24576efa86f820b2 100644 (file)
@@ -30,7 +30,7 @@ class Migration(migrations.Migration):
                 ('email', models.EmailField(max_length=75)),
                 ('token', models.CharField(max_length=100)),
                 ('sentat', models.DateTimeField(auto_now=True)),
-                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
+                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
             ],
         ),
     ]
index a5600bd88a60ce4d7d63cc8471e1bb8c29e52c82..b069f87dd190a6d7980ea630f73a9d2585f0e361 100644 (file)
@@ -18,7 +18,7 @@ class CommunityAuthSite(models.Model):
     cryptkey = models.CharField(max_length=100, null=False, blank=False,
                                 help_text="Use tools/communityauth/generate_cryptkey.py to create a key")
     comment = models.TextField(null=False, blank=True)
-    org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False)
+    org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False, on_delete=models.CASCADE)
     cooloff_hours = models.IntegerField(null=False, blank=False, default=0,
                                         help_text="Number of hours a user must have existed in the systems before allowed to log in to this site")
 
@@ -27,8 +27,8 @@ class CommunityAuthSite(models.Model):
 
 
 class CommunityAuthConsent(models.Model):
-    user = models.ForeignKey(User, null=False, blank=False)
-    org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False)
+    user = models.ForeignKey(User, null=False, blank=False, on_delete=models.CASCADE)
+    org = models.ForeignKey(CommunityAuthOrg, null=False, blank=False, on_delete=models.CASCADE)
     consentgiven = models.DateTimeField(null=False, blank=False)
 
     class Meta:
@@ -36,7 +36,7 @@ class CommunityAuthConsent(models.Model):
 
 
 class EmailChangeToken(models.Model):
-    user = models.OneToOneField(User, null=False, blank=False)
+    user = models.OneToOneField(User, null=False, blank=False, on_delete=models.CASCADE)
     email = models.EmailField(max_length=75, null=False, blank=False)
     token = models.CharField(max_length=100, null=False, blank=False)
     sentat = models.DateTimeField(null=False, blank=False, auto_now=True)
index f6cd669d1d16ac04d6a7a26a4b4ec2bc2638524a..8f11bb2ff6d2d33ac34874d16b25361f52b0d8f5 100644 (file)
@@ -44,11 +44,11 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='contributor',
             name='ctype',
-            field=models.ForeignKey(to='contributors.ContributorType'),
+            field=models.ForeignKey(to='contributors.ContributorType', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='contributor',
             name='user',
-            field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True),
+            field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE),
         ),
     ]
index 1ae9c1f8c660af4310d8c00037a44e3e0fa1b0b8..58f0ab9123973ecdd46cea1505fe0bf25246e5dd 100644 (file)
@@ -19,7 +19,7 @@ class ContributorType(models.Model):
 
 
 class Contributor(models.Model):
-    ctype = models.ForeignKey(ContributorType)
+    ctype = models.ForeignKey(ContributorType, on_delete=models.CASCADE)
     lastname = models.CharField(max_length=100, null=False, blank=False)
     firstname = models.CharField(max_length=100, null=False, blank=False)
     email = models.EmailField(null=False, blank=True)
@@ -27,7 +27,7 @@ class Contributor(models.Model):
     companyurl = models.URLField(max_length=100, null=True, blank=True, verbose_name='Company URL')
     location = models.CharField(max_length=100, null=True, blank=True)
     contribution = models.TextField(null=True, blank=True)
-    user = models.ForeignKey(User, null=True, blank=True)
+    user = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE)
 
     send_notification = True
     purge_urls = ('/community/contributors/', )
index f5f21e2bcb42a248cb8d38c1df2fbbe92573f561..c6e2e4e20108efe2ba0bf88b1ba59add8addcea4 100644 (file)
@@ -45,7 +45,7 @@ class Migration(migrations.Migration):
                 ('title', models.CharField(max_length=100)),
                 ('url', models.URLField()),
                 ('posttime', models.DateTimeField()),
-                ('feed', models.ForeignKey(to='core.ImportedRSSFeed')),
+                ('feed', models.ForeignKey(to='core.ImportedRSSFeed', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -101,7 +101,7 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='UserProfile',
             fields=[
-                ('user', models.OneToOneField(primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
+                ('user', models.OneToOneField(primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
                 ('sshkey', models.TextField(help_text='Paste one or more public keys in OpenSSH format, one per line.', verbose_name='SSH key', blank=True, validators=[pgweb.core.models.validate_sshkey])),
                 ('lastmodified', models.DateTimeField(auto_now=True)),
             ],
@@ -133,6 +133,6 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='organisation',
             name='orgtype',
-            field=models.ForeignKey(verbose_name='Organisation type', to='core.OrganisationType'),
+            field=models.ForeignKey(verbose_name='Organisation type', to='core.OrganisationType', on_delete=models.CASCADE),
         ),
     ]
index 0fea636bd93496033cfdccf27175b1194ed1b134..c4f8a4cda4384a3b345b254e68b1d460a6e3aff1 100644 (file)
@@ -128,7 +128,7 @@ class Organisation(models.Model):
     url = models.URLField(null=False, blank=False)
     email = models.EmailField(null=False, blank=True)
     phone = models.CharField(max_length=100, null=False, blank=True)
-    orgtype = models.ForeignKey(OrganisationType, null=False, blank=False, verbose_name="Organisation type")
+    orgtype = models.ForeignKey(OrganisationType, null=False, blank=False, verbose_name="Organisation type", on_delete=models.CASCADE)
     managers = models.ManyToManyField(User, blank=False)
     lastconfirmed = models.DateTimeField(null=False, blank=False, auto_now_add=True)
 
@@ -157,7 +157,7 @@ class ImportedRSSFeed(models.Model):
 
 
 class ImportedRSSItem(models.Model):
-    feed = models.ForeignKey(ImportedRSSFeed)
+    feed = models.ForeignKey(ImportedRSSFeed, on_delete=models.CASCADE)
     title = models.CharField(max_length=100, null=False, blank=False)
     url = models.URLField(null=False, blank=False)
     posttime = models.DateTimeField(null=False, blank=False)
@@ -195,7 +195,7 @@ def validate_sshkey(key):
 
 # Extra attributes for users (if they have them)
 class UserProfile(models.Model):
-    user = models.OneToOneField(User, null=False, blank=False, primary_key=True)
+    user = models.OneToOneField(User, null=False, blank=False, primary_key=True, on_delete=models.CASCADE)
     sshkey = models.TextField(null=False, blank=True, verbose_name="SSH key", help_text="Paste one or more public keys in OpenSSH format, one per line.", validators=[validate_sshkey, ])
     lastmodified = models.DateTimeField(null=False, blank=False, auto_now=True)
     block_oauth = models.BooleanField(null=False, blank=False, default=False,
index 0bd2383997bef366dceafcf273d0891f751a6728..acf0e1628bf654e517da544f0db0141d9bb54aef 100644 (file)
@@ -22,7 +22,7 @@ class Migration(migrations.Migration):
                 ('comment', models.TextField()),
                 ('posted_at', models.DateTimeField(auto_now_add=True)),
                 ('approved', models.BooleanField(default=False)),
-                ('submitter', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
+                ('submitter', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('-posted_at',),
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
                 ('file', models.CharField(max_length=64)),
                 ('title', models.CharField(max_length=256, null=True, blank=True)),
                 ('content', models.TextField(null=True, blank=True)),
-                ('version', models.ForeignKey(to='core.Version', db_column='version', to_field='tree')),
+                ('version', models.ForeignKey(to='core.Version', db_column='version', to_field='tree', on_delete=models.CASCADE)),
             ],
             options={
                 'db_table': 'docs',
index 89d326680ee41c8efca71566b3a03709599b4467..87afe1cac1a855a07bfb082d50698beb9c39f132 100644 (file)
@@ -5,7 +5,7 @@ from pgweb.core.models import Version
 class DocPage(models.Model):
     id = models.AutoField(null=False, primary_key=True)
     file = models.CharField(max_length=64, null=False, blank=False)
-    version = models.ForeignKey(Version, null=False, blank=False, db_column='version', to_field='tree')
+    version = models.ForeignKey(Version, null=False, blank=False, db_column='version', to_field='tree', on_delete=models.CASCADE)
     title = models.CharField(max_length=256, null=True, blank=True)
     content = models.TextField(null=True, blank=True)
 
index 9b0b8434e01a5522763e88fcc18885533737fc17..1faf86bf8a55074ce4330fe26cc27fab22955138 100644 (file)
@@ -74,9 +74,9 @@ class Migration(migrations.Migration):
                 ('description', models.TextField()),
                 ('price', models.CharField(max_length=200, blank=True)),
                 ('lastconfirmed', models.DateTimeField(auto_now_add=True)),
-                ('category', models.ForeignKey(to='downloads.Category')),
-                ('licencetype', models.ForeignKey(verbose_name='Licence type', to='downloads.LicenceType')),
-                ('org', models.ForeignKey(db_column='publisher_id', verbose_name='Organisation', to='core.Organisation')),
+                ('category', models.ForeignKey(to='downloads.Category', on_delete=models.CASCADE)),
+                ('licencetype', models.ForeignKey(verbose_name='Licence type', to='downloads.LicenceType', on_delete=models.CASCADE)),
+                ('org', models.ForeignKey(db_column='publisher_id', verbose_name='Organisation', to='core.Organisation', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('name',),
index 0da39456186012719aeedc17177c335578306d60..37176259aec0166ca48bf2679d24f68f5bcd7ef6 100644 (file)
@@ -27,10 +27,10 @@ class LicenceType(models.Model):
 class Product(models.Model):
     name = models.CharField(max_length=100, null=False, blank=False, unique=True)
     approved = models.BooleanField(null=False, default=False)
-    org = models.ForeignKey(Organisation, db_column="publisher_id", null=False, verbose_name="Organisation")
+    org = models.ForeignKey(Organisation, db_column="publisher_id", null=False, verbose_name="Organisation", on_delete=models.CASCADE)
     url = models.URLField(null=False, blank=False)
-    category = models.ForeignKey(Category, null=False)
-    licencetype = models.ForeignKey(LicenceType, null=False, verbose_name="Licence type")
+    category = models.ForeignKey(Category, null=False, on_delete=models.CASCADE)
+    licencetype = models.ForeignKey(LicenceType, null=False, verbose_name="Licence type", on_delete=models.CASCADE)
     description = models.TextField(null=False, blank=False)
     price = models.CharField(max_length=200, null=False, blank=True)
     lastconfirmed = models.DateTimeField(null=False, blank=False, auto_now_add=True)
index 645c174893f4a0e31fb23a8332d8f3092e3e7cf6..55af97ba0d29503998ab3c8b1ef8a9ce4bf80129 100644 (file)
@@ -25,9 +25,9 @@ class Migration(migrations.Migration):
                 ('enddate', models.DateField(verbose_name='End date')),
                 ('summary', models.TextField(help_text='A short introduction (shown on the events listing page)')),
                 ('details', models.TextField(help_text='Complete event description')),
-                ('country', models.ForeignKey(blank=True, to='core.Country', null=True)),
-                ('language', models.ForeignKey(default='eng', blank=True, to='core.Language', help_text='Primary language for event. When multiple languages, specify this in the event description', null=True)),
-                ('org', models.ForeignKey(verbose_name='Organisation', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.')),
+                ('country', models.ForeignKey(blank=True, to='core.Country', null=True, on_delete=models.CASCADE)),
+                ('language', models.ForeignKey(default='eng', blank=True, to='core.Language', help_text='Primary language for event. When multiple languages, specify this in the event description', null=True, on_delete=models.CASCADE)),
+                ('org', models.ForeignKey(verbose_name='Organisation', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('-startdate', '-enddate'),
index 9de2e83b494e147fbe2f9018579183c8cf1b9ac0..92168c7e77e24f9dd09b890c31f0197695621a98 100644 (file)
@@ -6,13 +6,13 @@ from pgweb.core.models import Country, Language, Organisation
 class Event(models.Model):
     approved = models.BooleanField(null=False, blank=False, default=False)
 
-    org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.")
+    org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.", on_delete=models.CASCADE)
     title = models.CharField(max_length=100, null=False, blank=False)
     isonline = models.BooleanField(null=False, default=False, verbose_name="Online event")
     city = models.CharField(max_length=50, null=False, blank=True)
     state = models.CharField(max_length=50, null=False, blank=True)
-    country = models.ForeignKey(Country, null=True, blank=True)
-    language = models.ForeignKey(Language, null=True, blank=True, default='eng', help_text="Primary language for event. When multiple languages, specify this in the event description")
+    country = models.ForeignKey(Country, null=True, blank=True, on_delete=models.CASCADE)
+    language = models.ForeignKey(Language, null=True, blank=True, default='eng', help_text="Primary language for event. When multiple languages, specify this in the event description", on_delete=models.CASCADE)
 
     badged = models.BooleanField(null=False, blank=False, default=False, verbose_name='Community event', help_text='Choose "Community event" if this is a community recognized event following the <a href="/community/recognition/#conferences" target="_blank">community event guidelines</a>.')
     description_for_badged = models.TextField(blank=True, null=True, verbose_name='Description for community event', help_text='DEPRECRATED: This was used in the beginning of community events to collect additional information.')
index dccb7514b0e1e27037cb938a8faec530e9d3e900..a68e86ea7defe2e2a65fd4634e1c017745d8affc 100644 (file)
@@ -41,6 +41,6 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='feature',
             name='group',
-            field=models.ForeignKey(to='featurematrix.FeatureGroup'),
+            field=models.ForeignKey(to='featurematrix.FeatureGroup', on_delete=models.CASCADE),
         ),
     ]
index 69c688b4d0e7f0826b047548bb5331a2a4c73f34..24873d023831a4cb83e5e472f14d9c95d23be15d 100644 (file)
@@ -25,7 +25,7 @@ class FeatureGroup(models.Model):
 
 
 class Feature(models.Model):
-    group = models.ForeignKey(FeatureGroup, null=False, blank=False)
+    group = models.ForeignKey(FeatureGroup, null=False, blank=False, on_delete=models.CASCADE)
     featurename = models.CharField(max_length=100, null=False, blank=False)
     featuredescription = models.TextField(null=False, blank=True)
     # WARNING! All fields that start with "v" will be considered versions!
index c084065f1d3b1c74dbd7a066afbb09af771244b7..faa8f668cde0959ee6087e117395c227100d06af 100644 (file)
@@ -38,6 +38,6 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='mailinglist',
             name='group',
-            field=models.ForeignKey(to='lists.MailingListGroup'),
+            field=models.ForeignKey(to='lists.MailingListGroup', on_delete=models.CASCADE),
         ),
     ]
index e0c56a52b83cdd2d8c90b7d639a05556ad1f96dc..4bcda5c1ee8591121614c9ab51a4ebdcf86f4c1d 100644 (file)
@@ -19,7 +19,7 @@ class MailingListGroup(models.Model):
 
 
 class MailingList(models.Model):
-    group = models.ForeignKey(MailingListGroup, null=False)
+    group = models.ForeignKey(MailingListGroup, null=False, on_delete=models.CASCADE)
     listname = models.CharField(max_length=64, null=False, blank=False, unique=True)
     active = models.BooleanField(null=False, default=False)
     description = models.TextField(null=False, blank=True)
index d19f22d831318b9afece5eac38103f584a957c76..825e576d6e2bff8df87375beef166acf8082892e 100644 (file)
@@ -20,7 +20,7 @@ class Migration(migrations.Migration):
                 ('date', models.DateField(default=datetime.date.today)),
                 ('title', models.CharField(max_length=200)),
                 ('content', models.TextField()),
-                ('org', models.ForeignKey(verbose_name='Organisation', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.')),
+                ('org', models.ForeignKey(verbose_name='Organisation', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('-date',),
index 863a02086de951568e612660c94558d555a6195e..4fe6f6407729b908c1f0c1dac633475e9cfe4690 100644 (file)
@@ -16,7 +16,7 @@ class NewsTag(models.Model):
 
 
 class NewsArticle(models.Model):
-    org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.")
+    org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.", on_delete=models.CASCADE)
     approved = models.BooleanField(null=False, blank=False, default=False)
     date = models.DateField(null=False, blank=False, default=date.today)
     title = models.CharField(max_length=200, null=False, blank=False)
index aacea9fbe94205e063c2d5e238f1bdacb53c7bda..23f7270b7cd4099c84e5b6927f8100ccd3608928 100644 (file)
@@ -34,7 +34,7 @@ class Migration(migrations.Migration):
                 ('provides_support', models.BooleanField(default=False)),
                 ('provides_hosting', models.BooleanField(default=False)),
                 ('interfaces', models.CharField(max_length=512, null=True, verbose_name='Interfaces (for hosting)', blank=True)),
-                ('org', models.OneToOneField(db_column='organisation_id', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.', verbose_name='organisation')),
+                ('org', models.OneToOneField(db_column='organisation_id', to='core.Organisation', help_text='If no organisations are listed, please check the <a href="/account/orglist/">organisation list</a> and contact the organisation manager or <a href="mailto:webmaster@postgresql.org">webmaster@postgresql.org</a> if none are listed.', verbose_name='organisation', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('org__name',),
index 36b7a178b5abd525b632790018f5926dd5f5681c..ad32ddba219c4498ce350b449b64fee4b4e8d4a3 100644 (file)
@@ -7,7 +7,7 @@ class ProfessionalService(models.Model):
     approved = models.BooleanField(null=False, blank=False, default=False)
 
     org = models.OneToOneField(Organisation, null=False, blank=False,
-                               db_column="organisation_id",
+                               db_column="organisation_id", on_delete=models.CASCADE,
                                verbose_name="organisation",
                                help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.")
     description = models.TextField(null=False, blank=False)
index 6ec92ef9132a0f45ea95eab6e8eb3336f61e65a9..48fe72ad5e870d3484c7c1f667cb3b83bd532829 100644 (file)
@@ -20,8 +20,8 @@ class Migration(migrations.Migration):
                 ('title', models.CharField(help_text="Title/Name of the PUG, e.g. 'NYC PostgreSQL User Group'", max_length=255)),
                 ('website_url', models.TextField(null=True, blank=True)),
                 ('mailing_list_url', models.TextField(null=True, blank=True)),
-                ('country', models.ForeignKey(to='core.Country')),
-                ('org', models.ForeignKey(blank=True, to='core.Organisation', help_text='Organisation that manages the PUG and its contents', null=True)),
+                ('country', models.ForeignKey(to='core.Country', on_delete=models.CASCADE)),
+                ('org', models.ForeignKey(blank=True, to='core.Organisation', help_text='Organisation that manages the PUG and its contents', null=True, on_delete=models.CASCADE)),
             ],
         ),
     ]
index c811297cae5c77cf7bb79497aeafdf9cab0be14f..83572c56eb668343fec8e3354625f426fdf24e6d 100644 (file)
@@ -5,8 +5,8 @@ class PUG(models.Model):
     """
     contains information about a local PostgreSQL user group
     """
-    country = models.ForeignKey('core.Country')
-    org = models.ForeignKey('core.Organisation', null=True, blank=True, help_text='Organisation that manages the PUG and its contents')
+    country = models.ForeignKey('core.Country', on_delete=models.CASCADE)
+    org = models.ForeignKey('core.Organisation', null=True, blank=True, help_text='Organisation that manages the PUG and its contents', on_delete=models.CASCADE)
     approved = models.BooleanField(null=False, blank=False, default=False)
     locale = models.CharField(max_length=255, help_text="Locale where the PUG meets, e.g. 'New York City'")
     title = models.CharField(max_length=255, help_text="Title/Name of the PUG, e.g. 'NYC PostgreSQL User Group'")
index 8a2a77f2e18e54c7a69aa1501dba5e089d08addc..e216fc19cf940bf98973c67998d0ae0c47b0dfa2 100644 (file)
@@ -32,7 +32,7 @@ class Migration(migrations.Migration):
                 ('vector_i', models.CharField(blank=True, max_length=1, verbose_name='Integrity Impact', choices=[('H', 'High'), ('L', 'Low'), ('N', 'None')])),
                 ('vector_a', models.CharField(blank=True, max_length=1, verbose_name='Availability Impact', choices=[('H', 'High'), ('L', 'Low'), ('N', 'None')])),
                 ('legacyscore', models.CharField(blank=True, max_length=1, verbose_name='Legacy score', choices=[('A', 'A'), ('B', 'B'), ('C', 'C'), ('D', 'D')])),
-                ('newspost', models.ForeignKey(blank=True, to='news.NewsArticle', null=True)),
+                ('newspost', models.ForeignKey(blank=True, to='news.NewsArticle', null=True, on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('-cvenumber',),
@@ -44,8 +44,8 @@ class Migration(migrations.Migration):
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('fixed_minor', models.IntegerField()),
-                ('patch', models.ForeignKey(to='security.SecurityPatch')),
-                ('version', models.ForeignKey(to='core.Version')),
+                ('patch', models.ForeignKey(to='security.SecurityPatch', on_delete=models.CASCADE)),
+                ('version', models.ForeignKey(to='core.Version', on_delete=models.CASCADE)),
             ],
         ),
         migrations.AddField(
index 6242e628d7352385973ab27c9e104bdbcb44f0d9..a961ff5234e7d5ee517212088cf49cc6aa459d6e 100644 (file)
@@ -52,7 +52,7 @@ def other_vectors_validator(val):
 
 class SecurityPatch(models.Model):
     public = models.BooleanField(null=False, blank=False, default=False)
-    newspost = models.ForeignKey(NewsArticle, null=True, blank=True)
+    newspost = models.ForeignKey(NewsArticle, null=True, blank=True, on_delete=models.CASCADE)
     cve = models.CharField(max_length=32, null=False, blank=True, validators=[cve_validator, ])
     cve_visible = models.BooleanField(null=False, blank=False, default=False)
     cvenumber = models.IntegerField(null=False, blank=False, db_index=True)
@@ -116,6 +116,6 @@ class SecurityPatch(models.Model):
 
 
 class SecurityPatchVersion(models.Model):
-    patch = models.ForeignKey(SecurityPatch, null=False, blank=False)
-    version = models.ForeignKey(Version, null=False, blank=False)
+    patch = models.ForeignKey(SecurityPatch, null=False, blank=False, on_delete=models.CASCADE)
+    version = models.ForeignKey(Version, null=False, blank=False, on_delete=models.CASCADE)
     fixed_minor = models.IntegerField(null=False, blank=False)
index 951f19d490be445bf04921e2a7e1347f5a5e92a4..d3b7c22ccbb38c70c6d51481409d0749657c0d5a 100644 (file)
@@ -33,7 +33,7 @@ class Migration(migrations.Migration):
                 ('name', models.CharField(max_length=128)),
                 ('url', models.URLField()),
                 ('logoname', models.CharField(max_length=64)),
-                ('country', models.ForeignKey(to='core.Country')),
+                ('country', models.ForeignKey(to='core.Country', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('name',),
@@ -54,7 +54,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='sponsor',
             name='sponsortype',
-            field=models.ForeignKey(to='sponsors.SponsorType'),
+            field=models.ForeignKey(to='sponsors.SponsorType', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='server',
index 215612b281cff033b8b26cfb26ac91aa2bd89837..68b3d4e895836ee0e760e836b2b4c727f9e9f8c0 100644 (file)
@@ -19,11 +19,11 @@ class SponsorType(models.Model):
 
 
 class Sponsor(models.Model):
-    sponsortype = models.ForeignKey(SponsorType, null=False)
+    sponsortype = models.ForeignKey(SponsorType, null=False, on_delete=models.CASCADE)
     name = models.CharField(max_length=128, null=False, blank=False)
     url = models.URLField(null=False, blank=False)
     logoname = models.CharField(max_length=64, null=False, blank=False)
-    country = models.ForeignKey(Country, null=False)
+    country = models.ForeignKey(Country, null=False, on_delete=models.CASCADE)
 
     purge_urls = ('/about/sponsors/', '/about/servers/', )
 
index b06313da6c39aa1e3e102cb0a9230eddcade16a0..e2b3bfa45ba797f157ec601d110a29d807d07c82 100644 (file)
@@ -38,7 +38,7 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='SurveyAnswer',
             fields=[
-                ('survey', models.OneToOneField(primary_key=True, serialize=False, to='survey.Survey')),
+                ('survey', models.OneToOneField(primary_key=True, serialize=False, to='survey.Survey', on_delete=models.CASCADE)),
                 ('tot1', models.IntegerField(default=0)),
                 ('tot2', models.IntegerField(default=0)),
                 ('tot3', models.IntegerField(default=0)),
index e593da0aba0a4b5c4ec32bfbfc082b6647df10b3..80f33c93d39dfb30b282c31937b1ca76c53c8034 100644 (file)
@@ -85,7 +85,7 @@ class Survey(models.Model):
 
 
 class SurveyAnswer(models.Model):
-    survey = models.OneToOneField(Survey, null=False, blank=False, primary_key=True)
+    survey = models.OneToOneField(Survey, null=False, blank=False, primary_key=True, on_delete=models.CASCADE)
     tot1 = models.IntegerField(null=False, default=0)
     tot2 = models.IntegerField(null=False, default=0)
     tot3 = models.IntegerField(null=False, default=0)