PK!rlAUTHORSAndreu VallbonaPK!/<< CHANGELOG.md # Change log ## 0.1.0 (2018-10-01) * Initial release. PK!PjLICENSECopyright (c) 2018 - APSL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK!$@ README.md[![Downloads](https://pepy.tech/badge/django-fast-migrations)](https://pepy.tech/project/django-fast-migrations) # Django-Fast-Migrations Command to speed up the application of migrations in a Django project. ## Installation Install using pip: ``` pip install django-fast-migrations ``` Then add ``'django_fast_migrations'`` to your ``INSTALLED_APPS``. ``` INSTALLED_APPS = [ ... 'django_fast_migrations', ] ``` ## Usage How to execute command: ./manage.py migrate_by_app The previous command only checks if there are applications with pending migrations. To execute the pending migrations we have to call the command: ./manage.py migrate_by_app When executed without parameters it **only checks** if there are applications with pending migrations Possible arguments: * ```--execute```: If pending migrations are found then execute them. * ```--database```: Nominates a database to synchronize. Defaults to the "default" database. PK! q"django_fast_migrations/__init__.py__version__ = '0.1.0' PK!-django_fast_migrations/management/__init__.pyPK!6django_fast_migrations/management/commands/__init__.pyPK!0Eh <django_fast_migrations/management/commands/migrate_by_app.py# -*- encoding: utf-8 -*- from django.core.management import call_command from django.core.management.base import BaseCommand, CommandError from django.db.migrations.loader import MigrationLoader from django.db import DEFAULT_DB_ALIAS, connections class Command(BaseCommand): """ Check if there are pending migrations. If there are pending migrations it's possible apply them by executing this command with the param --execute """ help = "Verify if there are migrations left and if so, execute them" def add_arguments(self, parser): parser.add_argument('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. Defaults to the "default" database.') parser.add_argument('--execute', action='store_true', dest='execute', default=False, help='Execute the migrations if pending, application by application') def handle(self, *args, **options): self.verbosity = options['verbosity'] self.stdout.write(' Verifying if the are migrations left '.center(100, '=')) # Get the database we're operating from db = options.get('database') execute_if_pending = options.get('execute') connection = connections[db] # process the apps in order to see if there are pending applications pending_apps = self.verify_pending(connection) if not pending_apps: self.stdout.write(' End of the process: not apps pending '.center(100, '=')) return if not execute_if_pending: # only warning that there are applications with pending migrations raise CommandError('There are this apps: {} with pending migrations'.format(pending_apps)) # at this point apps with pending migrations exists and proceed to execute them self.stdout.write('Migrating the apps: {}'.format(pending_apps).center(100, '.')) for app_name in pending_apps: self.stdout.write('Custom migrating app: ==={}==='.format(app_name)) call_command('migrate', app_name) self.stdout.write(' End of the process: applied migrations '.center(100, '=')) def verify_pending(self, connection): """ Obtains the ordered list of apps with pending migrations :param connection: :return: """ # Load migrations from disk/DB loader = MigrationLoader(connection, ignore_no_migrations=True) graph = loader.graph # Generate the plan plan = [] seen = set() for target in graph.leaf_nodes(): for migration in graph.forwards_plan(target): if migration not in seen: node = graph.node_map[migration] plan.append(node) seen.add(migration) apps_by_order = [] for node in plan: if node.key in loader.applied_migrations: continue app_name = node.key[0] if app_name not in apps_by_order: apps_by_order.append(app_name) if self.verbosity >= 2: self.stdout.write(' Showing pending apps by order '.center(100, '=')) self.stdout.write('{}'.format(apps_by_order)) if loader.applied_migrations: self.stdout.write(' Already applied '.center(100, '=')) self.stdout.write('{}'.format(loader.applied_migrations)) return apps_by_order PK!Pj.django_fast_migrations-0.1.0.dist-info/LICENSECopyright (c) 2018 - APSL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK!H WX,django_fast_migrations-0.1.0.dist-info/WHEEL A н#Z."jm)Afb~ڠO68oF04UhoAf f4=4h0k::wXPK!H͞*+C/django_fast_migrations-0.1.0.dist-info/METADATAT]O0}Z\`LVMT+Z < ԸmcHl/vZ_&98D"RCH`& r9/#eOC~٨sQT!sc`ĜW˛ޘuJ"J ,ZdT+ќ 7al:v kL"p9AǘB/0{ MTsH%Ê*:Od|?n5֌ @tuk#uƅ4)V ƕ!8|tmrCw]ZdZ$n?uذ6h*0NS̱^#1voQۅnCC3MV 8 4RaL& 6@*M:h sF%v#p5;(H2Eco<3cR@ոM6(}W,Ɲ~{wGQr/nЏs+{vWAs]Yr7!ĵr4*ݯ"7U#NՄd\4.. Ze)$^ -,KJigb`c/w_AS!YKFKAGBZgSZP;f2/sz6zkѕFATuk#:3]z?kor?Sa4MϜ$*+W*N ř(3g};OoPK!H $U-django_fast_migrations-0.1.0.dist-info/RECORDK@@@Ae.tTŧ_9$&=V**vs.BA:>B @'U? aYtcxi4_>W**w[w h~OA9 ޮ{CmRVf*վaj dUD0rYq{8Ťahw/kz lx QB&oq{\m+yeҲ'pZS>)YO6uÊ{Ә#?a\N;Cj騲ު޳z^-kicu>)e3D*vfi8z뾈NQUn9D#^15D;!.Q-XD?,78!%M~I}DsγTTFq8]‚RS,{} H?s섻zzUr&en¹j 3 PK!rlAUTHORSPK!/<< 4CHANGELOG.mdPK!PjLICENSEPK!$@ README.mdPK! q"django_fast_migrations/__init__.pyPK!- django_fast_migrations/management/__init__.pyPK!6i django_fast_migrations/management/commands/__init__.pyPK!0Eh < django_fast_migrations/management/commands/migrate_by_app.pyPK!Pj.django_fast_migrations-0.1.0.dist-info/LICENSEPK!H WX,Wdjango_fast_migrations-0.1.0.dist-info/WHEELPK!H͞*+C/django_fast_migrations-0.1.0.dist-info/METADATAPK!H $U-django_fast_migrations-0.1.0.dist-info/RECORDPK 3"