privex.helpers.django.is_database_synchronized

privex.helpers.django.is_database_synchronized(database: str) → bool[source]

Check if all migrations have been ran. Useful for preventing auto-running code accessing models before the tables even exist, thus preventing you from migrating…

>>> from django.db import DEFAULT_DB_ALIAS
>>> if not is_database_synchronized(DEFAULT_DB_ALIAS):
>>>     log.warning('Cannot run reload_handlers because there are unapplied migrations!')
>>>     return
Parameters

database (str) – Which Django database config is being used? Generally just pass django.db.DEFAULT_DB_ALIAS

Return bool

True if all migrations have been ran, False if not.