Skip to main content

Django Migration Rollback v1.1.0

A Django package used to just make the python manage.py migrate a little easier for Django apps that commit their migrations and want a way to rollback to a previous migration without needing to check what the which one it is via python manage.py showmigrations or in the project's git repository.

Features

Able to set which branch in a git repository to rollback to using the custom command migraterollback or if you wish to just rollback to a previous migration only via migrateprevious. Note in order to use the rollback with a git repository's branch feature with git the project must have a .git file present.

Django migraterollback command

❯ python manage.py migraterollback polls feature/really-cool-branch
Attempting to go back to rollback polls to latest migration on branch feature/really-cool-branch
Operations to perform:
    Target specific migration: 0006_question5, from polls
Running migrations:
    Rendering model states...
DONE
    Unapplying polls.0007_question6...
OK

This command is used to migrate a Django app back to the migration found in a repository's branch (this will also migrate to that migration if behind).

  • An app must be specified as the first argument after the command to indicate which app you wish to rollback.
  • By default if no argument is specified after the app, the branch main will be used.

Django migrateprevious command

❯ python manage.py migrateprevious polls
Attempting to go back to rollback polls to previous migration
Operations to perform:
    Target specific migration: 0005_question4, from polls
Running migrations:
    Rendering model states...
DONE
    Unapplying polls.0006_question5...
OK

This command is used to migrate a Django app back to the previously applied migration.

  • An app must be specified as the first argument after the command to indicate which app you wish to migrate to the previously applied migration.

Installing

From PyPi

pip install django-migration-rollback

From GitHub

pip install git+ssh://git@github.com/jdboisvert/django-migration-rollback

Quick start

Add "migration_rollback" to your INSTALLED_APPS in the settings.py like this:

    INSTALLED_APPS = [
        ...
        'migration_rollback',
    ]

Development

Getting started

# install pyenv (if necessary)
brew install pyenv pyenv-virtualenv
echo """
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
""" > ~/.zshrc
source ~/.zshrc

# create a virtualenv
pyenv install 3.11.0
pyenv virtualenv 3.11.0 django_migration_rollback
pyenv activate django_migration_rollback

# install dependencies
pip install -U pip
pip install -r requirements.txt -r requirements_dev.txt

Installing pre-commit hooks

pre-commit install

Metadata

Release files for django-migration-rollback 1.1.0

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-rollback 1.1.0
File Size Uploaded
django_migration_rollback-1.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-migration-rollback 1.1.0
File Interpreter ABI Platform
django_migration_rollback-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / django_migration_rollback-1.1.0.tar.gz

Download URL django_migration_rollback-1.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
66c23c567fa351e4cbf96654e3c951aac5a75255ea8b0f5f4b59fe4fc4c48b0b
BLAKE2b-256 checksum
How to use checksums
32d4fd5a1ae4eb3f7fe4f476b97fb1d933a298bef50044a0252ebfbb57f26f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Release files / django_migration_rollback-1.1.0-py3-none-any.whl

Download URL django_migration_rollback-1.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e19cc6337e4e1a75562bcb6f4984ff03387f4c69cd28574852f5b17e558a6def
BLAKE2b-256 checksum
How to use checksums
3546e1d74f5f39f12cf9db2cf1a5a4683694ab4ad822b7e7bb96bb201aae9dec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.1

1 release file

1.0.0

1 release file

0.1.2

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