{"id":20689970,"url":"https://github.com/tj-django/django-migration-fixer","last_synced_at":"2025-04-07T12:05:13.158Z","repository":{"id":37746840,"uuid":"369640452","full_name":"tj-django/django-migration-fixer","owner":"tj-django","description":"Resolve multiple leaf nodes error running django migrations.","archived":false,"fork":false,"pushed_at":"2025-03-26T06:05:15.000Z","size":2160,"stargazers_count":32,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T11:02:06.349Z","etag":null,"topics":["django","django-makemigrations","django-migration-fixer","django-migrations","django-models","django-project","github-actions","makemigrations","migrate","migration","migration-tool","migrations","resolves-migration-conflicts"],"latest_commit_sha":null,"homepage":"https://tj-django.github.io/django-migration-fixer/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tj-django.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-21T19:53:50.000Z","updated_at":"2025-03-26T06:04:37.000Z","dependencies_parsed_at":"2024-01-10T21:56:58.710Z","dependency_job_id":"51c0bbaf-3ffd-4bef-9619-e99d03603ed9","html_url":"https://github.com/tj-django/django-migration-fixer","commit_stats":{"total_commits":574,"total_committers":6,"mean_commits":95.66666666666667,"dds":"0.29442508710801396","last_synced_commit":"316a04662e46006c197cc78d92d33feaccb391ba"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-migration-fixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-migration-fixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-migration-fixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj-django%2Fdjango-migration-fixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj-django","download_url":"https://codeload.github.com/tj-django/django-migration-fixer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-makemigrations","django-migration-fixer","django-migrations","django-models","django-project","github-actions","makemigrations","migrate","migration","migration-tool","migrations","resolves-migration-conflicts"],"created_at":"2024-11-16T23:11:27.797Z","updated_at":"2025-04-07T12:05:13.141Z","avatar_url":"https://github.com/tj-django.png","language":"Python","funding_links":["https://www.buymeacoffee.com/jackton1"],"categories":[],"sub_categories":[],"readme":"![logo](https://user-images.githubusercontent.com/17484350/124649379-6821ad00-de66-11eb-9b0e-890913c65311.png)\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/1e607eb508f64cefad18f50d6ff920cf)](https://www.codacy.com/gh/tj-django/django-migration-fixer/dashboard?utm_source=github.com\\\u0026utm_medium=referral\\\u0026utm_content=tj-django/django-migration-fixer\\\u0026utm_campaign=Badge_Coverage)\n[![codecov](https://codecov.io/gh/tj-django/django-migration-fixer/branch/main/graph/badge.svg?token=peNs0PpfP6)](https://codecov.io/gh/tj-django/django-migration-fixer)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1e607eb508f64cefad18f50d6ff920cf)](https://www.codacy.com/gh/tj-django/django-migration-fixer/dashboard?utm_source=github.com\\\u0026utm_medium=referral\\\u0026utm_content=tj-django/django-migration-fixer\\\u0026utm_campaign=Badge_Grade)\n[![Test](https://github.com/tj-django/django-migration-fixer/actions/workflows/test.yml/badge.svg)](https://github.com/tj-django/django-migration-fixer/actions/workflows/test.yml)\n[![Upload Python Package](https://github.com/tj-django/django-migration-fixer/actions/workflows/deploy.yml/badge.svg)](https://github.com/tj-django/django-migration-fixer/actions/workflows/deploy.yml)\n\n[![PyPI](https://img.shields.io/pypi/v/django-migration-fixer)](https://pypi.python.org/pypi/django-migration-fixer)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-migration-fixer)](https://pypi.python.org/pypi/django-migration-fixer) [![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-migration-fixer)](https://pypi.python.org/pypi/django-migration-fixer) [![Downloads](https://pepy.tech/badge/django-migration-fixer)](https://pepy.tech/project/django-migration-fixer)\n[![Public workflows that use this action.](https://img.shields.io/endpoint?url=https%3A%2F%2Fused-by.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Dtj-django%2Fdjango-migration-fixer%26badge%3Dtrue)](https://github.com/search?o=desc\\\u0026q=tj-django+django-migration-fixer+language%3AYAML\\\u0026s=\\\u0026type=Code)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# django-migration-fixer\n\nResolve 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 manage.py makemigrations --merge`.\n\n## Table of Contents\n\n*   [Features](#features)\n*   [Installation](#installation)\n    *   [Add `migration_fixer` to your INSTALLED\\_APPS](#add-migration_fixer-to-your-installed_apps)\n*   [Usage](#usage)\n*   [Example](#example)\n    *   [After merging the default branch](#after-merging-the-default-branch)\n    *   [After running django-migration-fixer](#after-running-django-migration-fixer)\n*   [Assumptions](#assumptions)\n    *   [Specifying a different default branch](#specifying-a-different-default-branch)\n*   [Setup using Github Actions](#setup-using-github-actions)\n    *   [Inputs](#inputs)\n*   [Test Platforms](#test-platforms)\n*   [Found a Bug?](#found-a-bug)\n\n## Features\n\n*   Resolve migration conflicts on Pull Request branches\n*   Resolve migration conflicts on the default branch **(NOT RECOMMENDED)**\n\n## Installation\n\n```bash\n$ pip install django-migration-fixer\n```\n\n### Add `migration_fixer` to your INSTALLED\\_APPS\n\n```python\n\nINSTALLED_APPS = [\n    ...,\n    \"migration_fixer\",\n    ...,\n]\n```\n\n## Usage\n\nMerge the changes from the default branch or the target branch of the pull request.\n\n```bash\n$ git checkout main # OR: develop/another parent feature branch\n$ git pull\n$ git checkout feature/xxxx\n$ git merge main\n```\n\nFix the migration conflicts\n\n```bash\n$ python manage.py makemigrations --fix\n```\n\nBy default this uses `main` as the default branch\n\n## Example\n\n### After merging the default branch\n\n![Screen Shot 2021-07-06 at 2 21 46 PM](https://user-images.githubusercontent.com/17484350/124648930-d7e36800-de65-11eb-99a3-bf806ecfd32b.png)\n\n### After running django-migration-fixer\n\n![Screen Shot 2021-07-06 at 2 22 31 PM](https://user-images.githubusercontent.com/17484350/124649105-0feaab00-de66-11eb-80f3-7987d67b361d.png)\n\n## Assumptions\n\nThe final migration on the default branch would be used as the base for all subsequent migrations.\n\n### Specifying a different default branch\n\nRun:\n\n```bash\n$ python manage.py makemigrations -b master --fix\n```\n\n## Setup using Github Actions\n\n\u003e NOTE: :warning:\n\u003e\n\u003e *   To get this action to work you'll need to install [django-migration-fixer](#installation) and update your `INSTALLED_APPS` setting.\n\n### Inputs\n\n|   Input       |    type     |  required      |  default                      |  description               |\n|:-------------:|:-----------:|:--------------:|:-----------------------------:|:--------------------------:|\n| managepy-path |  `string`   |    `true`     | `./manage.py`                  | The location of manage.py. |\n| default-branch |  `string`  |    `false`     |  `${{ github.base_ref }}`      |  The default branch or \u003cbr\u003e target branch of a Pull request.  |\n| force-update |  `string`  |    `false`     |        |  Force update the target branch \u003cbr\u003e locally when git fetch fails.  |\n| skip-default-branch-update |  `string`  |    `false`     |        |  Skip pulling the latest \u003cbr\u003e changes from the default branch.  |\n\n```yaml\nname: Fix django migrations\n\non:\n  pull_request:\n    branches:\n      - main\n\njobs:\n  fix-migrations:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 0\n\n      - name: Set up Python\n        uses: actions/setup-python@v2\n        with:\n          python-version: '3.6.x'\n\n      - name: Upgrade pip\n        run: |\n          pip install -U pip\n\n      - name: Install project dependencies\n        run: |\n          make install\n\n      - name: Run django-migration-fixer\n        uses: tj-django/django-migration-fixer@v1.3.6\n        with:\n          managepy-path: /path/to/manage.py\n\n      - name: Verify Changed files\n        uses: tj-actions/verify-changed-files@v7.1\n        id: verify-changed-files\n        with:\n          files: |\n             /path/to/migrations\n\n      - name: Commit migration changes\n        if: steps.verify-changed-files.outputs.files_changed == 'true'\n        run: |\n          git config --local user.email \"github-actions[bot]@users.noreply.github.com\"\n          git config --local user.name \"github-actions[bot]\"\n          git add /path/to/migrations\n          git commit -m \"Updated migrations\"\n\n      - name: Push migration changes\n        if: steps.verify-changed-files.outputs.files_changed == 'true'\n        uses: ad-m/github-push-action@master\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          branch: ${{ github.ref }}\n```\n\nSee: [here](https://github.com/tj-django/django-clone/blob/main/.github/workflows/migration-fixer.yml) for a working example.\n\n## Test Platforms\n\n*   [`ubuntu-*`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n*   [`macos-*`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n*   [`windows-*`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)\n\n## Found a Bug?\n\nTo file a bug or submit a patch, please head over to [django-migration-fixer on github](https://github.com/tj-django/django-migration-fixer/issues).\n\nIf you feel generous and want to show some extra appreciation:\n\nSupport me with a :star:\n\n[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]\n\n[buymeacoffee]: https://www.buymeacoffee.com/jackton1\n\n[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-django%2Fdjango-migration-fixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj-django%2Fdjango-migration-fixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj-django%2Fdjango-migration-fixer/lists"}