From db487f513d0a11bb4be35ea37d2cfb571d6edba1 Mon Sep 17 00:00:00 2001 From: James Gordon Date: Fri, 14 Apr 2017 10:13:39 -0500 Subject: [PATCH] Skip dropping/re-adding of constraints and indexes for MySQL #1499 --- .../management/commands/loadcalaccessrawfile.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/calaccess_raw/management/commands/loadcalaccessrawfile.py b/calaccess_raw/management/commands/loadcalaccessrawfile.py index 38fe517e..714e2c74 100644 --- a/calaccess_raw/management/commands/loadcalaccessrawfile.py +++ b/calaccess_raw/management/commands/loadcalaccessrawfile.py @@ -147,9 +147,6 @@ def load(self): "{} not configured in DATABASES settings.".format(self.database) ) - # temporarily drop model and field constraints and indexes - self.model.objects.drop_constraints_and_indexes() - # set up database connection self.connection = connections[self.database] self.cursor = self.connection.cursor() @@ -161,16 +158,17 @@ def load(self): 'django.db.backends.postgresql_psycopg2' 'django.contrib.gis.db.backends.postgis' ): + # temporarily drop model and field constraints and indexes + self.model.objects.drop_constraints_and_indexes() self.load_postgresql() + # re-add model and field constraints and indexes + self.model.objects.add_constraints_and_indexes() else: self.failure("Sorry your database engine is unsupported") raise CommandError( "Only MySQL and PostgresSQL backends supported." ) - # re-add model and field constraints and indexes - self.model.objects.add_constraints_and_indexes() - def load_dat(self): """ Takes a model and a csv file and loads it into dat.