Package: django-migration-fixer
django-migration-fixerResolve django makemigrationsmultiple leaf nodes in the migration graphby ensuring that migration files and dependencies are always ordered regardless of remote changes, without having to runpython manage.py makemigrations --merge.Table of ContentsFeaturesInstallationAddmigration_fixerto your INSTALLED_APPSUsageExampleAfter merging the default branchAfter running django-migration-fixerAssumptionsSpecifying a different default branchSetup using Github ActionsInputsTest PlatformsFound a Bug?FeaturesResolve migration conflicts on Pull Request branchesResolve migration conflicts on the default branch(NOT RECOMMENDED)Installation$pipinstalldjango-migration-fixerAddmigration_fixerto your INSTALLED_APPSINSTALLED_APPS=[...,"migration_fixer",...,]UsageMerge the changes from the default branch or the target branch of the pull request.$gitcheckoutmain# OR: develop/another parent feature branch$gitpull
$gitcheckoutfeature/xxxx
$gitmergemainFix the migration conflicts$pythonmanage.pymakemigrations--fixBy default this usesmainas the default branchExampleAfter merging the default branchAfter running django-migration-fixerAssumptionsThe final migration on the default branch would be used as the base for all subsequent migrations.Specifying a different default branchRun:$pythonmanage.pymakemigrations-bmaster--fixSetup using Github ActionsNOTE: :warning:To get this action to work you'll need to installdjango-migration-fixerand update yourINSTALLED_APPSsetting.InputsInputtyperequireddefaultdescriptionmanagepy-pathstringtrue./manage.pyThe location of manage.py.default-branchstringfalse${{ github.base_ref }}The default branch ortarget branch of a Pull request.force-updatestringfalseForce update the target branchlocally when git fetch fails.skip-default-branch-updatestringfalseSkip pulling the latestchanges from the default branch.name:Fix django migrationson:pull_request:branches:-mainjobs:fix-migrations:runs-on:ubuntu-lateststeps:-uses:actions/checkout@v2with:fetch-depth:0-name:Set up Pythonuses:actions/setup-python@v2with:python-version:'3.6.x'-name:Upgrade piprun:|pip install -U pip-name:Install project dependenciesrun:|make install-name:Run django-migration-fixeruses:tj-django/django-migration-fixer@v1.3.6with:managepy-path:/path/to/manage.py-name:Verify Changed filesuses:tj-actions/verify-changed-files@v7.1id:verify-changed-fileswith:files:|/path/to/migrations-name:Commit migration changesif:steps.verify-changed-files.outputs.files_changed == 'true'run:|git config --local user.email "github-actions[bot]@users.noreply.github.com"git config --local user.name "github-actions[bot]"git add /path/to/migrationsgit commit -m "Updated migrations"-name:Push migration changesif:steps.verify-changed-files.outputs.files_changed == 'true'uses:ad-m/github-push-action@masterwith:github_token:${{ secrets.GITHUB_TOKEN }}branch:${{ github.ref }}See:https://github.com/tj-django/django-clonefor a working example.Test Platformsubuntu-*macos-*windows-*Found a Bug?To file a bug or submit a patch, please head over todjango-migration-fixer on github.If you feel generous and want to show some extra appreciation:Support me with a :star: