Skip to main content

Django Migration Snapshots

https://img.shields.io/badge/license-BSD-blue.svg https://readthedocs.org/projects/django-migration-snapshots/badge/?version=stable&style=flat https://img.shields.io/pypi/v/django-migration-snapshots.svg https://img.shields.io/pypi/pyversions/django-migration-snapshots https://img.shields.io/badge/code%20style-black-000000.svg

Capture snapshots of your django project’s migration history. These snapshots are represented as a directed graph using pygraphviz in both textual and graphical formats.

Documentation

The full documentation is at https://django-migration-snapshots.readthedocs.io.

Quickstart

Install Django Migration Snapshots:

pip install django-migration-snapshots

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    "migration_snapshots",
    ...
)

1) Execute management command to create snapshot

# creates snapshot of entire migration history
python manage.py create_snapshot

# filter migrations before applied date (YYYY-MM-DD)
python manage.py create_snapshot --date="2022-10-15"

2) Create object programmatically or from the admin panel

MigrationSnapshot.objects.create(output_format="pdf")

3) Automatically create migration snapshots with the post_migrate signal

from django.apps import AppConfig
from django.db.models.signals import post_migrate

def my_snapshot_callback(sender, **kwargs):
    # Create migration snapshot
    MigrationSnapshot.objects.create(output_format="pdf")

class MyAppConfig(AppConfig):
    ...

    def ready(self):
        # send signal only once after all migrations execute
        post_migrate.connect(my_snapshot_callback, sender=self)

Text Snapshot

digraph {
    "admin/0001_initial" -> "auth/0001_initial"
    "admin/0001_initial" -> "contenttypes/0001_initial"
    "admin/0002_logentry_remove_auto_add" -> "admin/0001_initial"
    "admin/0003_logentry_add_action_flag_choices" -> "admin/0002_logentry_remove_auto_add"
    "auth/0001_initial" -> "contenttypes/0001_initial"
    "auth/0002_alter_permission_name_max_length" -> "auth/0001_initial"
    ...
}

Graphical Snapshot

JPEG visual representation of migration history

Features

  • MigrationSnapshot data model

  • Supported output formats

    • BMP, CGIMAGE, DOT_CANON, DOT, GV, XDOT, XDOT12, XDOT14, EPS, EXR, FIG, GD, GIF, GTK, ICO, CMAP, ISMAP, IMAP, CMAPX, IMAGE_NP, CMAPX_NP, JPG, JPEG, JPE, JPEG_2000, JSON, JSON0, DOT_JSON, XDOT_JSON, PDF, PIC, PICT, APPLE_PICT, PLAIN_TEXT, PLAIN_EXT, PNG, POV_RAY, PS_PDF, PSD, SGI, SVG, SVGZ, TGA, TIF, TIFF, TK, VML, VMLZ, VRML, WBMP, WEBP, XLIB, X11

  • View migration history based on the miigration’s applied timestamp

TODO’s

  • Additional test coverage

  • Setup tox

  • Additional filters in management command (ie; per app, per model, etc.)

Local Development

make install
make test

Deployment

make build
make deploy

License

This project is provided under the BSD License.

Metadata

Release files for django-migration-snapshots 0.5.1

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-migration-snapshots 0.5.1
File Size Uploaded
django-migration-snapshots-0.5.1.tar.gz 12.7 kB Details

Release files / django-migration-snapshots-0.5.1.tar.gz

Download URL django-migration-snapshots-0.5.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d7057cc9227a12b8a7333cd5ead3394197edd8190c54192b4c8e25516de2c2cc
BLAKE2b-256 checksum
How to use checksums
5b84cadfe82a024a5fa655456d59bf2ab7a3a995b2969db78092b81eb30f6673
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.4

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 release file

0.5.0

1 release file

0.0.1

1 release file

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