Skip to main content

Sync Django migrations to match the dev branch, then checkout dev.

Project description

django-sync-migrations

From a feature branch, sync Django migrations to match the dev branch, then checkout dev. Use when on a feature branch with migrations you want to discard before switching back to dev.

A time saver when you are doing a lot of reviews of Django code and find yourself undoing feature branch migrations to match the base branch before you switch back to it.

Install

From your Django project:

pip install django-sync-migrations

Or without installing (requires uv):

uvx django-sync-migrations

Run

From your Django project directory (the one with manage.py):

django-sync-migrations              # reset migrations to dev, then checkout dev
django-sync-migrations --dry-run   # show what would be done
django-sync-migrations --branch develop
django-sync-migrations --skip-checkout   # only reset migrations, don’t checkout

Resequence after rebase (-r)

When you rebase your feature branch onto dev, migrations from dev can leave your feature's migrations with conflicting or "behind" numbering, which would require a merge migration later. Use -r to detect migrations that exist only on your branch (not on dev), then optionally delete them and run makemigrations so new migrations get numbers that follow dev.

Default is dry-run (no files changed). Use --apply to delete and run makemigrations; you'll be prompted to confirm unless you pass --yes.

django-sync-migrations -r                    # dry-run: list feature-only migrations
django-sync-migrations -r --apply            # delete them and run makemigrations (prompt)
django-sync-migrations -r --apply --yes      # apply without confirmation
django-sync-migrations -r -b main            # compare against main instead of dev

Requires a Django project (with manage.py), git, and a reachable database. The tool runs manage.py migrate using your project’s Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_sync_migrations-0.3.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_sync_migrations-0.3.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file django_sync_migrations-0.3.0.tar.gz.

File metadata

  • Download URL: django_sync_migrations-0.3.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_sync_migrations-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e75b8ff547b29a8676f460fc484af1a3780252c273a56802c3f5398342d4236a
MD5 d88f31807d88a032fdec1922e8b206f2
BLAKE2b-256 12e328f75a92bd34adf79db3067193eee2c32470134081ea24a59ca4c8a36c0e

See more details on using hashes here.

File details

Details for the file django_sync_migrations-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: django_sync_migrations-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_sync_migrations-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 814de8e7aff7269ef4743187aed2fe83cea481634c1df43e60a0c2ae85e33eba
MD5 8c7196b70e142d7e92fd586f1efdda15
BLAKE2b-256 7a5bd528fc28cec7cf8e7592a2b70846daabd4c580bf86503d1fad37553ad685

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page