From 53c1798a2259247f72848abfbf616e7551545af5 Mon Sep 17 00:00:00 2001
From: Alice Heaton <aliceh@aptivate.org>
Date: Tue, 14 Jul 2015 17:48:36 +0100
Subject: [PATCH] Disable mysql foreign key checks on staging, production and
 jenkins as well. See
 http://stackoverflow.com/questions/6178816/django-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails

---
 django/website/local_settings.py.jenkins    | 2 +-
 django/website/local_settings.py.production | 2 +-
 django/website/local_settings.py.staging    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/django/website/local_settings.py.jenkins b/django/website/local_settings.py.jenkins
index e3bff451..f131e9cf 100644
--- a/django/website/local_settings.py.jenkins
+++ b/django/website/local_settings.py.jenkins
@@ -20,7 +20,7 @@ DATABASES = {
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
         'OPTIONS': {
-            "init_command": "SET storage_engine=INNODB",
+            "init_command": "SET storage_engine=INNODB;SET foreign_key_checks = 0;",
         }
     }
 }
diff --git a/django/website/local_settings.py.production b/django/website/local_settings.py.production
index ac4d17a2..0785b579 100644
--- a/django/website/local_settings.py.production
+++ b/django/website/local_settings.py.production
@@ -20,7 +20,7 @@ DATABASES = {
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
         'OPTIONS': {
-            "init_command": "SET storage_engine=INNODB",
+            "init_command": "SET storage_engine=INNODB;SET foreign_key_checks = 0;",
         }
     }
 }
diff --git a/django/website/local_settings.py.staging b/django/website/local_settings.py.staging
index 77804ec5..095494e7 100644
--- a/django/website/local_settings.py.staging
+++ b/django/website/local_settings.py.staging
@@ -16,7 +16,7 @@ DATABASES = {
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
         'OPTIONS': {
-            "init_command": "SET storage_engine=INNODB",
+            "init_command": "SET storage_engine=INNODB;SET foreign_key_checks = 0;",
         }
     }
 }
-- 
GitLab