Django Migration Cleaner is a Django management command that allows you to easily delete migration files for specified apps or for all apps within your Django project. This can be useful for cleaning up your project during development.
You can install Django Migration Cleaner via pip:
pip install django-migration-cleanerAdd django_migration_cleaner to your INSTALLED_APPS in your Django project's settings.py:
INSTALLED_APPS = [
...
'django_migration_cleaner',
...
]Usage
Delete Migrations for Specific Apps To delete migration files for specific apps, run the following command:
python manage.py delete_migrations app_name1 app_name2Replace app_name1, app_name2, etc. with the names of the apps for which you want to delete the migration files.
python manage.py delete_migrations app_name --lastpython manage.py delete_migrations app_name1 app_name2 --lastReplace app_name1, app_name2, etc. with the names of the apps for which you want to delete the last migration file.
To delete migration files for all apps within your Django project, run the following command:
python manage.py delete_migrations --allExample
python manage.py delete_migrations myapp anotherappThis will delete all migration files for myapp and anotherapp, except for the init.py files in their migration directories.
This project is licensed under the MIT License. See the LICENSE file for more details.
Acknowledgements
This project was inspired by the need to clean up migration files during Django project development.
For any questions or suggestions, feel free to open an issue or contact the project maintainer.