Resolve migration errors
Project description
django-migration-fixer
Resolve django makemigrations multiple leaf nodes in the migration graph
by ensuring that migration files and dependencies are always ordered regardless of remote changes.
Features
- 100% test coverage.
- Maintain a consistent migration history when conflicts occur as a result of changes made using different versions of the default branch.
- Resolve migration conflicts on PR 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 default branch i.e
main|master|develop
depending on your setup.
Example
After merging the default branch
After running django-migration-fixer
Assumptions
The final migration on the default branch would be used as the base for all subsequent migrations.
Installation
$ pip install django-migration-fixer
Add migration_fixer
to your INSTALLED_APPS
INSTALLED_APPS = [
...,
"migration_fixer",
...,
]
Usage
$ python manage.py makemigrations --fix
By default this uses main
as the default branch
Specifying a different default branch
Run:
$ python manage.py makemigrations -b master --fix
Setup using Github Actions
NOTE: :warning:
- To get this action to work you'll need to install django-migration-fixer and update your
INSTALLED_APPS
setting.
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.1.3
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.
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 :star:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-migration-fixer-1.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09ee8bae8c62a5864957a90b09ba369f7bb829a56b7e297988158ca4ff0d4192 |
|
MD5 | 973c813864c76a85facf3f9af4c16e0a |
|
BLAKE2b-256 | b5ed000de5cb72a93460dcd2c41e48f3295a9ba284f9b049235efdf5babacf75 |
Close
Hashes for django_migration_fixer-1.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 373a598d56d36498c0c4e62a2e7cc14395f5586af5b64d1a1708c7f299161394 |
|
MD5 | bb1927e4e3c7c4b91f1dc0c56e4d219e |
|
BLAKE2b-256 | 8bb8be19a85d36122f8949e02a61b34b2423517d68a2bdd654192f6aa94cadf8 |