You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
django-migration-fixer
v1.2.1
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 manage.py makemigrations --merge
- 100% test coverage.
- Maintain a consistent migration history when conflicts occur as a result of changes made using different versions of the target branch.
- Resolve migration conflicts on Pull Request branches
- Resolve migration conflicts on the default branch (NOT RECOMMENDED)
- Supports default migration modules i.e (
0001_....py
) - Re-number all migrations using the last migration on the target branch.
The final migration on the default branch would be used as the base for all subsequent migrations.
$ pip install django-migration-fixer
INSTALLED_APPS = [
...,
"migration_fixer",
...,
]
$ python manage.py makemigrations --fix
By default this uses main
as the default branch
Run:
$ python manage.py makemigrations -b master --fix
NOTE:
⚠️
- 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 |
./manage.py |
The location of manage.py. |
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. |
name: Fix django migrations
on:
pull_request:
branches:
- main
jobs:
fix-migrations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
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.2.0
with:
managepy-path: /path/to/manage.py
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v7.1
id: verify-changed-files
with:
files: |
/path/to/migrations
- name: Commit migration changes
if: 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/migrations
git commit -m "Update migrations"
- name: Push migration changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
See: https://github.com/tj-django/django-clone for a working example.
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 ⭐