Skip to content

Commit

Permalink
Skip dropping/re-adding of constraints and indexes for MySQL #1499
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonje committed Apr 14, 2017
1 parent 354a1a6 commit db487f5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions calaccess_raw/management/commands/loadcalaccessrawfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.
Expand Down

0 comments on commit db487f5

Please sign in to comment.