Django in 10 minutes
DBLift ships a Django app with three management commands and a pending-migrations system check. It complements Django's ORM migrations rather than replacing them: use it for raw SQL, heterogeneous databases, cross-dialect work and rollback. DBLift keeps its own history table and never touches django_migrations.
extra · dblift[django]
Install
pip install "dblift[django]"
Settings
settings.py
INSTALLED_APPS = [
# ...
"dblift.integrations.django",
]
DBLIFT_MIGRATIONS_DIR = BASE_DIR / "migrations"
# Optional
DBLIFT_DATABASE_ALIAS = "default"
DBLIFT_DATABASE_URL = "postgresql+psycopg://user:pass@host/db"The connection is read from settings.DATABASES[DBLIFT_DATABASE_ALIAS], which defaults to "default". Five Django backends map straight to a driver; set DBLIFT_DATABASE_URL to bypass the mapping for anything else. An unmapped ENGINE raises ImproperlyConfigured rather than guessing.
| Django ENGINE | Driver DBLift connects with |
|---|---|
postgresql, postgis | postgresql+psycopg |
mysql | mysql+pymysql |
sqlite3 | sqlite |
oracle | oracle+oracledb |
mssql, sql_server | mssql+pymssql |
Commands
python manage.py dblift_migrate
python manage.py dblift_validate
python manage.py dblift_info
- dblift_migrate — applies pending migrations. A failed run raises a CommandError carrying the reported message, so the deploy step fails.
- dblift_validate — checks checksums, order and applied state.
- dblift_info — prints pending and failed history status. A failed (
success=0) row is not pending and is listed separately. Repair guidance stays ondblift_validate.
All three build their own client, run the operation, and close it again — Django system checks are skipped for these commands so a pending-migration warning cannot block the command that fixes it.
System check
manage.py check and runserver emit warning dblift.W001 when migrations are pending, with the hint to run manage.py dblift_migrate. If the database is unreachable or the configuration is incomplete, the check emits dblift.W002 rather than returning an empty result — an empty result would look like a clean bill of health for a check that never ran. Both warnings are non-blocking.
Make stale schema fail the deploy
The check only warns. Run python manage.py dblift_migrate as a deploy step, or register your own Django check that escalates dblift.W001 to an error.
Read next
- Django raw SQL migrations next to the ORM: views, indexes, the pending-migration check, one failure, and one rollback, next to
makemigrations. - Flyway for a Python shop: import existing Flyway history and keep the SQL files.
- DBLift vs Alembic: how SQL-file migrations and model-diff migrations differ, and when each fits.
- CI/CD: gate a pull request on
dblift_validateanddblift_info.