Beispiel #1
0
 def handle_noargs(self, **options):
     verbosity = int(options.get('verbosity', 0))
     migrate = options.get('migrate', False)
     options['migrate'] = False
     
     shared_apps, isolated_apps = get_apps()
     
     try:
         if len(shared_apps) > 0:
             if verbosity:
                 print "------------------"
                 print "SHARED APPS syncdb"
                 print "------------------\n"
             
             syncdb_apps(shared_apps, **options)
         
         if len(isolated_apps) == 0:
             return
         
         for schema in Schema.objects.active():
             if verbosity:
                 print "\n-------------------------------"
                 print   "ISOLATED APPS syncdb on schema: %s" % schema.name
                 print   "-------------------------------\n"
                 
             syncdb_apps(isolated_apps, schema.name, **options)
     finally:
         load_post_syncdb_signals()
     
     if migrate:
         management.call_command("migrate")
Beispiel #2
0
    def handle_noargs(self, **options):
        verbosity = int(options.get("verbosity", 0))
        migrate = options.get("migrate", False)
        options["migrate"] = False

        shared_apps, isolated_apps = get_apps()

        try:
            if len(shared_apps) > 0:
                if verbosity:
                    print "------------------"
                    print "SHARED APPS syncdb"
                    print "------------------\n"

                syncdb_apps(shared_apps, schema=None, **options)

            if len(isolated_apps) == 0:
                return

            schema_list = [x.name for x in Schema.objects.active()]
            for schema in schema_list:
                if verbosity:
                    print "\n-------------------------------"
                    print "ISOLATED APPS syncdb on schema: %s" % schema
                    print "-------------------------------\n"

                syncdb_apps(isolated_apps, schema=schema, **options)
        finally:
            load_post_syncdb_signals()

        if migrate:
            db.connection.close()
            db.connection.connection = None
            management.call_command("migrate")
    def handle(self, app=None, target=None, skip=False, merge=False,
    backwards=False, fake=False, db_dry_run=False, show_list=False,
    database=DEFAULT_DB_ALIAS, delete_ghosts=False, ignore_ghosts=False,
    **options):
        if not 'south' in settings.INSTALLED_APPS:
            raise CommandError('South is not installed.')

        verbosity = int(options.get('verbosity', 0))
        shared, isolated = get_apps()

        if options.get('all_apps', False):
            target = app
            app = None

        # Migrate each app
        if app:
            apps = [app]
        else:
            apps = settings.INSTALLED_APPS

        options.update({
            'target': target,
            'skip': skip,
            'merge': merge,
            'backwards': backwards,
            'fake': fake,
            'db_dry_run': db_dry_run,
            'show_list': show_list,
            'database': database,
            'delete_ghosts': delete_ghosts,
            'ignore_ghosts': ignore_ghosts
        })

        shared_apps = [x for x in get_migration_candidates(shared) if x in apps]
        isolated_apps = [x for x in get_migration_candidates(isolated) if x in apps]

        try:
            if len(shared_apps) > 0:
                if verbosity:
                    print "---------------------"
                    print "SHARED APPS migration"
                    print "---------------------\n"

                migrate_apps(shared_apps, None, **options)

            if len(isolated_apps) == 0:
                return

            schema_list = [x.name for x in Schema.objects.active()]
            for schema in schema_list:
                if verbosity:
                    print "\n----------------------------------"
                    print   "ISOLATED APPS migration on schema: %s" % schema
                    print   "----------------------------------\n"
                migrate_apps(isolated_apps, schema=schema, **options)
        finally:
            load_post_syncdb_signals()
Beispiel #4
0
 def wrapper(_apps, *args, **kwargs):
     load_post_syncdb_signals()
     for _app in _apps:
         migrate.Command().execute(_app, **kwargs)
Beispiel #5
0
 def wrapper(_apps, *args, **kwargs):
     load_post_syncdb_signals()
     return syncdb.Command().execute(**kwargs)