Skip to main content

django-migrations-diff

PyPI version Python versions License

CLI to compare Django migrations between two snapshots.

This may be useful when you need to compare migrations in the same app between different branches.

Installation

pip install django-migrations-diff

Requirements

  • Python 3.6 or higher

How to use

# show help
mdiff help

# Create migrations snapshot
mdiff <snapshot>

# Compare two snapshots
mdiff <snapshot_1> <snapshot_2>

# Compare two snapshots (get number of diffent migrations)
mdiff <snapshot_1> <snapshot_2> --number

# List of all snapshots
mdiff list

# Remove all or specific snapshots
mdiff rm all
mdiff rm <snapshot_1> <snapshot_2>

# Get current version
mdiff -v

Example

For example, you need to compare “master” and “develop” branches.

git checkout master # go to "master" branch

mdiff master # create "master" snapshot

git checkout develop # go to "develop" branch

mdiff develop # create "develop" shapshot

mdiff master develop # compare two snapshots

Output will be like:

┌─────────────┬───────────────────┬───────────────────┐
│ APPLICATION │ MASTER            │ DEVELOP           │
├─────────────┼───────────────────┼───────────────────┤
│ app.authors │ 0004_migration.py │ ---               │
│             │ ---               │ 0005_migration.py │
├─────────────┼───────────────────┼───────────────────┤
│ app.users   │ 0003_migration.py │ 0003_migration.py │
└─────────────┴───────────────────┴───────────────────┘
 Stats for snapshot DEVELOP: +1 -1 *1

Explanation:

  1. Snapshot MASTER has 0004_migration.py but DEVELOP misses it

  2. Snapshot DEVELOP has 0005_migration.py but MASTER misses it

  3. Both MASTER and DEVELOP have 0003_migration.py migration, but it differs inside

  4. Stats show that DEVELOP snapshot has 1 new, 1 missing and 1 changed migration

CI/CD configuration

This package also can be used to detect new migrations in CI/CD pipelines. For example, following stage in .gitlab-ci.yml will fail if there are new migrations in current branch in comparison to master branch.

chechcheck:
  stage: tests
  script:
    - pip install django-migrations-diff==2.0.4  # PLEASE, CHECK CURRENT VERSION
    - git merge-base origin/master HEAD | xargs git checkout
    - mdiff master
    - git checkout ${CI_COMMIT_REF_NAME}
    - mdiff ${CI_COMMIT_REF_NAME}
    - mdiff master ${CI_COMMIT_REF_NAME}
    - (if [[ $(mdiff master ${CI_COMMIT_REF_NAME} --number) == 0 ]]; then echo "No new migrations"; else exit 1; fi;)
  allow_failure: true

NOTE: This is not full stage descriptions, this is only example.

Metadata

Release files for django-migrations-diff 2.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-migrations-diff 2.0.5
File Size Uploaded Provenance Actions
django-migrations-diff-2.0.5.tar.gz 10.6 kB Without provenance Details for django-migrations-diff-2.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-migrations-diff 2.0.5
File Interpreter ABI Platform Actions
django_migrations_diff-2.0.5-py3-none-any.whl Python 3 none any Details for django_migrations_diff-2.0.5-py3-none-any.whl

Total release size: 21.0 kB

Release files / django-migrations-diff-2.0.5.tar.gz

Download URL django-migrations-diff-2.0.5.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c42313f2f1fd68abc7a566bd7051655926446407c76f5988cc0d436219ccd89b
BLAKE2b-256 checksum
How to use checksums
df94544bc368a7fd98d209d4228c59670572660c952775b2d9ecafc32c7c9a26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.10

Release files / django_migrations_diff-2.0.5-py3-none-any.whl

Download URL django_migrations_diff-2.0.5-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed7077092086a3711cb8c28e650e6789de5530c0ec5418bdff2f77e44b9ef84d
BLAKE2b-256 checksum
How to use checksums
82d302fa0b4db28103ca533a7c6e6df00fa4059bee8a9775d8d20ef2d8ed98ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.10

Security for django-migrations-diff 2.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page