migrations¶
Module: espressodb.management.checks.migrations
Cross checks for local migrations and models compared to state of database
-
exception
MigrationStateError
(header, data=None)[source]¶ Error which is raised if the local state of models or migrations does not reflect the database.
-
__init__
(header, data=None)[source]¶ Initialize MigrationStateError and prepares custom error method.
- Parameters
header (
str
) – What is the reason for raising the error? E.g., changes, conflicts, …data (
Optional
[Dict
[str
,List
[str
]]]) – Dictionary where keys are app names and values are migration names.
-
-
check_migration_state
(exclude=None)[source]¶ Checks if the state of local migrations is represented by the database.
This code follows the logic of Djangos showmigrations https://github.com/django/django/blob/master/django/core/management/commands/showmigrations.py
- Parameters
exclude (
Optional
[List
[str
]]) – List of apps to ignore when checking migration states.- Raises
MigrationStateError – If the loader detects conflicts or unapplied changes.
- Future:
It might be desirable to allow partial checks by, e.g., providing an app_labels argument.
-
check_model_state
()[source]¶ Checks if the state of local models is represented by migration files.
This code follows the logic of Djangos makemigrations https://github.com/django/django/blob/master/django/core/management/commands/makemigrations.py
- Raises
MigrationStateError – If the loader detects conflicts or unapplied changes.
- Future:
It might be desirable to allow partial checks by, e.g., providing an app_labels argument.
-
run_migration_checks
()[source]¶ Runs all migration checks at once
- In order:
- Raises
MigrationStateError – If the loader detects conflicts or unapplied changes.