@@ -0,0 +1,1634 @@
+import os%0A%0Afrom django.apps import apps%0Afrom django.db.migrations.state import ProjectState%0Afrom django.core.management.base import BaseCommand%0Afrom django.db.migrations.loader import MigrationLoader%0Afrom django.db.migrations.writer import MigrationWriter%0Afrom django.db.migrations.autodetector import MigrationAutodetector%0A%0Afrom share.core import ProviderAppConfig%0Afrom share.core import ProviderMigration%0A%0A%0Aclass Command(BaseCommand):%0A    can_import_settings = True%0A%0A    def write_migration(self, migration):%0A        loader = MigrationLoader(None, ignore_no_migrations=True)%0A        autodetector = MigrationAutodetector(loader.project_state(), ProjectState.from_apps(apps),)%0A        changes = autodetector.arrange_for_graph(changes=%7B'share': %5Bmigration%5D%7D, graph=loader.graph,)%0A%0A        for m in changes%5B'share'%5D:%0A            writer = MigrationWriter(m)%0A            with open(writer.path, 'wb') as fp:%0A                fp.write(writer.as_string())%0A%0A    def handle(self, *args, **options):%0A        changes = %7B%7D%0A        for config in apps.get_app_configs():%0A            if isinstance(config, ProviderAppConfig):%0A                changes%5Bconfig.name%5D = %5BProviderMigration(config).migration()%5D%0A%0A        for migrations in changes.values():%0A            for m in migrations:%0A                writer = MigrationWriter(m)%0A                os.makedirs(os.path.dirname(writer.path), exist_ok=True)%0A%0A                with open(os.path.join(os.path.dirname(writer.path), '__init__.py'), 'wb') as fp:%0A                    fp.write(writer.as_string())%0A%0A                with open(writer.path, 'wb') as fp:%0A                    fp.write(writer.as_string())%0A

Add a command to create provider migrations