Skip to main content

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

Project description

django-sync-migrations

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.

Install / run (from your Django project directory)

If published on PyPI:

uvx django-sync-migrations
uvx django-sync-migrations --dry-run
uvx django-sync-migrations --branch develop
uvx django-sync-migrations --skip-checkout

Or run from GitHub (no PyPI):

uvx --from git+https://github.com/sponrad/django-sync-migrations django-sync-migrations
uvx --from git+https://github.com/sponrad/django-sync-migrations@main django-sync-migrations  # pin to branch/tag

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


Publishing to PyPI

One-time setup

  1. Create a PyPI account at pypi.org and enable 2FA.
  2. Create the project on PyPI (or it will be created on first publish): go to pypi.org/manage/account/ → “Create a new project”, name it django-sync-migrations.
  3. Create an API token (Account → API tokens): scope it to this project (or “Entire account” for testing). Copy the token; you won’t see it again.

Manual publish (each release)

From the repo root:

# Bump version (optional; or edit pyproject.toml by hand)
uv version --bump patch

# Build
uv build

# Upload to PyPI (set token once: export UV_PUBLISH_TOKEN=pypi-...)
uv publish --token $(grep UV_PUBLISH_TOKEN .env 2>/dev/null | cut -d= -f2)
# or: uv publish  # if UV_PUBLISH_TOKEN is already in the environment

For Test PyPI first: add to pyproject.toml under [tool.uv] (or use a separate config) an index with publish-url = "https://test.pypi.org/legacy/" and run uv publish --index testpypi.

Automated publish (recommended): Trusted Publisher

No tokens: push a tag and the workflow publishes to PyPI.

  1. GitHub: Create an environment named pypi (Settings → Environments).
  2. PyPI: Project → “Publishing” → “Add a new trusted publisher” → GitHub. Set:
    • Owner/repository: sponrad/django-sync-migrations
    • Workflow name: publish.yml
    • Environment name: pypi
  3. Release: Tag and push. The workflow in .github/workflows/publish.yml runs on tags v* (e.g. v0.1.0).
git tag -a v0.1.0 -m "Release 0.1.0"
git push --tags

PyPI: Trusted publishers.

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.1.0.tar.gz (4.8 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.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_sync_migrations-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3b2b39d602daf1705f220f2bbb67fa3d124f6d1e26000e7783cf1a54000fd91
MD5 832be050b4cbb0b49c5062d0cd634f7e
BLAKE2b-256 92ed3bc72d7bf3178d2731bdb2bb32d68be5fef679cfd0736a481466fb16f733

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_sync_migrations-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3af084b1631238e0d4aa279e90725ff1982ed0a5e469b67d14d3f70c844ef720
MD5 e34e2d5c074a7fc0c2b9923ea5f758ce
BLAKE2b-256 6c29d0153f461796e4420793c50eceaa10e8c079c00db89bc973e05910cb8e1e

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