Now properly deleting the tenant if an error occurs while creating it

This commit is contained in:
Bernardo Pires 2014-12-26 21:21:24 +01:00
parent 8f7d239049
commit 1e6bd4028c
1 changed files with 3 additions and 1 deletions

View File

@ -39,8 +39,10 @@ class TenantMixin(models.Model):
try:
self.create_schema(check_if_exists=True, verbosity=verbosity)
post_schema_sync.send(sender=TenantMixin, tenant=self)
finally:
except:
# We failed creating the tenant, delete what we created and re-raise the exception
self.delete(force_drop=True)
raise
def delete(self, force_drop=False, *args, **kwargs):
"""