Database¶
- django_docker_helpers.db.ensure_caches_alive(max_retries=100, retry_timeout=5, exit_on_failure=True)[source]¶
Checks every cache backend alias in
settings.CACHES
until it becomes available. Aftermax_retries
attempts to reach any backend are failed it returnsFalse
. Ifexit_on_failure
is set it shuts down withexit(1)
.It sets the
django-docker-helpers:available-check
key for every cache backend to ensure it’s receiving connections. If check is passed the key is deleted.- Parameters
exit_on_failure (
bool
) – set toTrue
if there’s no sense to continuemax_retries (int) – a number of attempts to reach cache backend, default is
100
retry_timeout (int) – a timeout in seconds between attempts, default is
5
- Return type
bool
- Returns
True
if all backends are availableFalse
if any backend check failed
- django_docker_helpers.db.ensure_databases_alive(max_retries=100, retry_timeout=5, exit_on_failure=True)[source]¶
Checks every database alias in
settings.DATABASES
until it becomes available. Aftermax_retries
attempts to reach any backend are failed it returnsFalse
. Ifexit_on_failure
is set it shuts down withexit(1)
.For every database alias it tries to
SELECT 1
. If no errors raised it checks the next alias.- Parameters
exit_on_failure (
bool
) – set toTrue
if there’s no sense to continuemax_retries (int) – number of attempts to reach every database; default is
100
retry_timeout (int) – timeout in seconds between attempts
- Return type
bool
- Returns
True
if all backends are available,False
if any backend check failed
- django_docker_helpers.db.migrate(*argv)[source]¶
Runs Django migrate command.
- Return type
bool
- Returns
always
True
- django_docker_helpers.db.modeltranslation_sync_translation_fields()[source]¶
Runs
modeltranslation
’ssync_translation_fields
manage.py command:execute_from_command_line(['./manage.py', 'sync_translation_fields', '--noinput'])
- Return type
bool
- Returns
None
if modeltranslation is not specified isINSTALLED_APPS
,True
if all synced.