Beispiel #1
0
    def handle_noargs(self, hostname=None, schemaname=None, allschemas=True, **options):
        self.debug = bool(options.get('verbosity', 0))
        
        public_apps = get_public_apps()
        if (hostname is None and schemaname is None) and len(public_apps):
            with RunWithApps(public_apps):
                installed_apps = list(settings.INSTALLED_APPS)
                self.logging('Syncing "master" for %d apps:' % len(installed_apps))
                schema_store.reset_path()
                for app in installed_apps:
                    self.logging('\t- %s' % app)
                super(Command, self).handle_noargs(**options)
                self.logging('\t* Synced')

        schemas = get_schemas(hostname=hostname, schemaname=schemaname, allschemas=allschemas)
        isolated_apps = get_isolated_apps()
        
        for schema in schemas:
            with schema:
                with RunWithApps(isolated_apps):
                    installed_apps = list(settings.INSTALLED_APPS)
                    self.logging('\n')
                    self.logging('Syncing "%s" for %d apps:' % (schema, len(installed_apps)))
                    for app in installed_apps:
                        self.logging('\t- %s' % app)
                    super(Command, self).handle_noargs(**options)
                    self.logging('\t* Synced')
Beispiel #2
0
    def handle_noargs(self,
                      hostname=None,
                      schemaname=None,
                      allschemas=True,
                      **options):
        self.debug = bool(options.get('verbosity', 0))

        public_apps = get_public_apps()
        if (hostname is None and schemaname is None) and len(public_apps):
            with RunWithApps(public_apps):
                installed_apps = list(settings.INSTALLED_APPS)
                self.logging('Syncing "master" for %d apps:' %
                             len(installed_apps))
                schema_store.reset_path()
                for app in installed_apps:
                    self.logging('\t- %s' % app)
                super(Command, self).handle_noargs(**options)
                self.logging('\t* Synced')

        schemas = get_schemas(hostname=hostname,
                              schemaname=schemaname,
                              allschemas=allschemas)
        isolated_apps = get_isolated_apps()

        for schema in schemas:
            with schema:
                with RunWithApps(isolated_apps):
                    installed_apps = list(settings.INSTALLED_APPS)
                    self.logging('\n')
                    self.logging('Syncing "%s" for %d apps:' %
                                 (schema, len(installed_apps)))
                    for app in installed_apps:
                        self.logging('\t- %s' % app)
                    super(Command, self).handle_noargs(**options)
                    self.logging('\t* Synced')
Beispiel #3
0
    def handle(self, *args, **options):
        self.debug = bool(options.get('verbosity', 0))
        hostname = options.pop('hostname')
        schemaname = options.pop('schemaname')
        allschemas = options.pop('allschemas')

        args = list(args)
        appName = args[0] if len(args) > 0 else None
        public_apps = [
            app for app in get_public_apps(appName=appName) if migratable(app)
        ]

        if (hostname is None and schemaname is None) and len(public_apps):
            self.logging('Migrating "master" for %d apps:' % len(public_apps))
            schema_store.reset_path()
            for app in public_apps:
                self.logging('\t- ' + app)
                if len(args) > 0:
                    args[0] = app
                else:
                    args.append(app)
                super(Command, self).handle(*args, **options)

        schemas = get_schemas(hostname=hostname,
                              schemaname=schemaname,
                              allschemas=allschemas)
        isolated_apps = [
            app for app in get_isolated_apps(appName=appName)
            if migratable(app)
        ]

        for schema in schemas:
            self.logging('\n')
            with schema:
                self.logging('Migrating "%s" for %d apps:' %
                             (schema, len(isolated_apps)))
                for app in isolated_apps:
                    with RunWithApps([app]):
                        if len(args) > 0:
                            args[0] = app
                        else:
                            args.append(app)

                        super(Command, self).handle(*args, **options)
                        self.logging('\t- %s (Migrated)' % app)

        if hostname is None and schemaname is None and len(schemas):
            migrations = []
            with schemas[0]:
                for migration in MigrationHistory.objects.all():
                    migrations.append(migration)
            MigrationHistory.objects.all().delete()
            for migration in migrations:
                migration.save()
Beispiel #4
0
 def handle(self, *args, **options):
     self.debug = bool(options.get('verbosity', 0))
     hostname = options.pop('hostname')
     schemaname = options.pop('schemaname')
     allschemas = options.pop('allschemas')
     
     args = list(args)
     appName = args[0] if len(args) > 0 else None
     public_apps = [app for app in get_public_apps(appName=appName) if migratable(app)]
     
     if (hostname is None and schemaname is None) and len(public_apps):
         self.logging('Migrating "master" for %d apps:' % len(public_apps))
         schema_store.reset_path()
         for app in public_apps:
             self.logging('\t- ' + app)
             if len(args) > 0:
                 args[0] = app
             else:
                 args.append(app)
             super(Command, self).handle(*args, **options)
     
     schemas = get_schemas(hostname=hostname, schemaname=schemaname, allschemas=allschemas)
     isolated_apps = [app for app in get_isolated_apps(appName=appName) if migratable(app)]
     
     for schema in schemas:
         self.logging('\n')
         with schema:
             self.logging('Migrating "%s" for %d apps:' % (schema, len(isolated_apps)))
             for app in isolated_apps:
                 with RunWithApps([app]):
                     if len(args) > 0:
                         args[0] = app
                     else:
                         args.append(app)
                 
                     super(Command, self).handle(*args, **options)
                     self.logging('\t- %s (Migrated)' % app)
                     
     if hostname is None and schemaname is None and len(schemas):
         migrations = []
         with schemas[0]:
             for migration in MigrationHistory.objects.all():
                 migrations.append(migration)
         MigrationHistory.objects.all().delete()
         for migration in migrations:
             migration.save()