mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 14:48:02 -05:00
fixed startup failing if fix tree fails
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import OperationalError, ProgrammingError
|
from django.db import OperationalError, ProgrammingError
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
|
from recipes.settings import DEBUG
|
||||||
|
|
||||||
|
|
||||||
class CookbookConfig(AppConfig):
|
class CookbookConfig(AppConfig):
|
||||||
name = 'cookbook'
|
name = 'cookbook'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
# post_save signal is only necessary if using full-text search on postgres
|
# post_save signal is only necessary if using full-text search on postgres
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']:
|
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
||||||
|
'django.db.backends.postgresql']:
|
||||||
import cookbook.signals # noqa
|
import cookbook.signals # noqa
|
||||||
|
|
||||||
# when starting up run fix_tree to:
|
# when starting up run fix_tree to:
|
||||||
@@ -21,6 +26,14 @@ class CookbookConfig(AppConfig):
|
|||||||
Keyword.fix_tree(fix_paths=True)
|
Keyword.fix_tree(fix_paths=True)
|
||||||
Food.fix_tree(fix_paths=True)
|
Food.fix_tree(fix_paths=True)
|
||||||
except OperationalError:
|
except OperationalError:
|
||||||
|
if DEBUG:
|
||||||
|
traceback.print_exc()
|
||||||
pass # if model does not exist there is no need to fix it
|
pass # if model does not exist there is no need to fix it
|
||||||
except ProgrammingError:
|
except ProgrammingError:
|
||||||
|
if DEBUG:
|
||||||
|
traceback.print_exc()
|
||||||
pass # if migration has not been run database cannot be fixed yet
|
pass # if migration has not been run database cannot be fixed yet
|
||||||
|
except Exception:
|
||||||
|
if DEBUG:
|
||||||
|
traceback.print_exc()
|
||||||
|
pass # dont break startup just because fix could not run, need to investigate cases when this happens
|
||||||
|
|||||||
Reference in New Issue
Block a user