You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dependabot[bot] f25d040214 Bump django from 4.0.6 to 4.1 1 week ago
.github chore(deps): update wearerequired/lint-action action to v2.0.1 1 month ago
django_migration_fixer Update 3 months ago
docs Update docs. (#140) 11 months ago
migration_fixer Updated submodule. 6 months ago
.coveragerc Update .coveragerc 1 year ago
.editorconfig Updated .editorconfig 8 months ago
.gitignore Added documentation (#19) 1 year ago
.gitmodules Improve test coverage (#43) 1 year ago
.pep8speaks.yml Updated .pep8speaks.yml 1 year ago
.pre-commit-config.yaml [] pre-commit autoupdate (#249) 1 month ago
.pyup.yml Updated .pyup.yml 1 year ago
.whitesource Added .whitesource 1 year ago Upgraded v1.3.4 → v1.3.5 (#197) 6 months ago Added 1 year ago
LICENSE Update LICENSE 1 year ago Update 11 months ago
Makefile Updated requirements.txt and fixed Makefile. (#153) 11 months ago Update (#241) 3 months ago
action.yml Update action.yml 11 months ago Increase test coverage. (#62) 1 year ago Added mypy configuration and updated tox test. (#14) 1 year ago
mkdocs.yml Update docs. (#140) 11 months ago
mypy.ini Added mypy configuration and updated tox test. (#14) 1 year ago
renovate.json Added renovate.json 1 year ago
requirements.txt Bump django from 4.0.6 to 4.1 1 week ago
setup.cfg Upgraded v1.3.4 → v1.3.5 (#197) 6 months ago Revert "chore(deps): update dependency pymdown-extensions to >=9.5,<9.6" (#246) 2 months ago
tox.ini Update tox.ini 1 year ago


Codacy Badge codecov Total alerts Language grade: Python Codacy Badge

Test Upload Python Package Run linters Updates Code style: black

PyPI PyPI - Python Version PyPI - Django Version Downloads Public workflows that use this action.


Resolve django makemigrations multiple leaf nodes in the migration graph by ensuring that migration files and dependencies are always ordered regardless of remote changes, without having to run python makemigrations --merge.

Table of Contents


  • Resolve migration conflicts on Pull Request branches
  • Resolve migration conflicts on the default branch (NOT RECOMMENDED)


$ pip install django-migration-fixer

Add migration_fixer to your INSTALLED_APPS



Merge the changes from the default branch or the target branch of the pull request.

$ git checkout main # OR: develop/another parent feature branch
$ git pull
$ git checkout feature/xxxx
$ git merge main

Fix the migration conflicts

$ python makemigrations --fix

By default this uses main as the default branch


After merging the default branch

Screen Shot 2021-07-06 at 2 21 46 PM

After running django-migration-fixer

Screen Shot 2021-07-06 at 2 22 31 PM


The final migration on the default branch would be used as the base for all subsequent migrations.

Specifying a different default branch


$ python makemigrations -b master --fix

Setup using Github Actions


  • To get this action to work you'll need to install django-migration-fixer and update your INSTALLED_APPS setting.


Input type required default description
managepy-path string true ./ The location of
default-branch string false ${{ github.base_ref }} The default branch or
target branch of a Pull request.
force-update string false Force update the target branch
locally when git fetch fails.
skip-default-branch-update string false Skip pulling the latest
changes from the default branch.
name: Fix django migrations

      - main

    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
          fetch-depth: 0

      - name: Set up Python
        uses: actions/setup-python@v2
          python-version: '3.6.x'

      - name: Upgrade pip
        run: |
                    pip install -U pip

      - name: Install project dependencies
        run: |
                    make install

      - name: Run django-migration-fixer
        uses: tj-django/django-migration-fixer@v1.3.5
          managepy-path: /path/to/

      - name: Verify Changed files
        uses: tj-actions/verify-changed-files@v7.1
        id: verify-changed-files
          files: |

      - name: Commit migration changes
        if: steps.verify-changed-files.outputs.files_changed == 'true'
        run: |
          git config --local "github-actions[bot]"
          git config --local "github-actions[bot]"
          git add /path/to/migrations
          git commit -m "Updated migrations"          

      - name: Push migration changes
        if: steps.verify-changed-files.outputs.files_changed == 'true'
        uses: ad-m/github-push-action@master
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

See: for a working example.

Test Platforms

Found a Bug?

To file a bug or submit a patch, please head over to django-migration-fixer on github.

If you feel generous and want to show some extra appreciation:

Support me with a

Buy me a coffee