Skip to content

Commit

Permalink
#424: Added IF EXISTS to DROP SCHEMA queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandervaneck authored and goodtune committed Feb 22, 2017
1 parent 93a0780 commit 3579735
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tenant_schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def delete(self, force_drop=False, *args, **kwargs):

if schema_exists(self.schema_name) and (self.auto_drop_schema or force_drop):
cursor = connection.cursor()
cursor.execute('DROP SCHEMA %s CASCADE' % self.schema_name)
cursor.execute('DROP SCHEMA IF EXISTS %s CASCADE' % self.schema_name)

super(TenantMixin, self).delete(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion tenant_schemas/test/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def tearDownClass(cls):
cls.tenant.delete()

cursor = connection.cursor()
cursor.execute('DROP SCHEMA test CASCADE')
cursor.execute('DROP SCHEMA IF EXISTS test CASCADE')

@classmethod
def sync_shared(cls):
Expand Down
2 changes: 1 addition & 1 deletion tenant_schemas/tests/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUpClass(cls):
# a blank public schema for this set of tests.
connection.set_schema_to_public()
cursor = connection.cursor()
cursor.execute('DROP SCHEMA %s CASCADE; CREATE SCHEMA %s;'
cursor.execute('DROP SCHEMA IF EXISTS %s CASCADE; CREATE SCHEMA %s;'
% (get_public_schema_name(), get_public_schema_name()))
super(BaseTestCase, cls).setUpClass()

Expand Down

0 comments on commit 3579735

Please sign in to comment.