Skip to content

Data Migration Safety

Purpose

Reduce schema-change risk through explicit pre-checks, controlled execution, and post-change validation.

Pre-Migration Checklist

  • migration reviewed for reversibility and data-loss risk
  • backup/restore path validated
  • dependency ordering verified
  • affected modules identified for regression testing

Execution Pattern

docker compose run --rm app python manage.py makemigrations
docker compose run --rm app python manage.py migrate
docker compose run --rm app python manage.py showmigrations

Post-Migration Validation

  • run manage.py check
  • run impacted module tests
  • run smoke suite
  • verify critical workflows and logs

Common Risks

Risk Mitigation
irreversible schema/data transform document rollback plan and test restore path
hidden downstream breakage run change-impact and targeted suites
partial deploy state enforce migration completion checks before release
Rollback caution

Not all migrations are safely reversible; validate rollback strategy before production execution.