Package: django-migrate-project
Djangomanagement commands for project-wide (editable) migrations.OverviewThe django-migrate-project app aims to add management commands to make running
full project migrations more sane and controllable. The concept is pretty
simple: first collect any unapplied migrations into per-app migration files,
then review and modify as need be, and finally apply the migrations.By staging and consolidating unapplied migrations in a way that they can be
edited and reviewed before applying, more confidence is gained that a rogue
migration won’t damage production tables. The collected and consolidated
migrations are listed as replacements for the individual app migrations they
represent so once they have been applied everything is in the same state as if
the individual app migrations has been applied via ‘migrate’.RequirementsRequires Django 1.7+ and as such Python 2.7+ as wellInstallationSimply usepipto install:$ pip install django-migrate-projectTo be of any usedjango-migrate-projectmust be added to the Django project
viaINSTALLED_APPSin the projectsettings.pyfile:INSTALLED_APPS = (
    ...
    'django_migrate_project',
    ...
)UsageTwo new management commands provide the core functionality. To gather up any
unapplied migrations for the project simply run:$ python manage.py collectmigrationsThe default collection location isBASE_DIR/pending_migrations. If the project’ssettings.pydoes not have aBASE_DIRthen a directory path must be provided
using the--output-diroption.The collected migrations are grouped per-app and have the filename format of<app_label>_project.py. These files can be edited to taste in order to
change the migration, the only important bit is to keep thereplacesanddependenciesfields in the migration the same, as those allow the bookkeeping
to be kept accurate.Collected migrations are applied via:$ python manage.py applymigrationsThe default directory path is used again if possible, otherwise the path must
be provided via the--input-diroption.Finally, migrations can be unapplied easily as well, returning the migration
state to what it was before by running:$ python manage.py applymigrations --unapplyExperimentalStarting with v0.2.0 there’s also the capability to generate project-level
migrations as a way to capture monkey-patched models and other changes that
shouldn’t create migrations in a third-party app.To use this functionality, first create a top-levelmigrationsdirectory
with a__init__.pyfile to make it a Python package. Then run the following
command to create any new project-level migrations (changes not present in
third-party app migrations):$ python manage.py makeprojectmigrationsAssuming there are any migrations to generate, the top-levelmigrationsdirectory should now be populated and you can migrate the project using:$ python manage.py migrateprojectAs with theapplymigrationscommand,migrateprojectalso has an easy
unapply functionality:$ python manage.py migrateproject --unapplyWhile this functionality is well covered by tests it will remain ‘experimental’
until it gets a bit more real world use.ContributingContributions are welcome, just create a pull request or issue on theGitHub repositoryfor the project.