def seed_migrations(self, stop_at=None):
        # @@@ the command-line interface needs to be re-thinked
        # TODO: this needs to be able to handle multi-db when you're
        #       specifying stop_at
        if stop_at is None and self.args:
            stop_at = self.args[0]
        
        if stop_at:
            try:
                stop_at = int(stop_at)
            except ValueError:
                raise CommandError("Invalid --seed migration")
            except __HOLE__:
                raise CommandError(
                    "Usage: ./manage.py upgradedb --seed [stop_at]"
                )

        all_migrations = get_pending_migrations(
            self.path, self.databases, stop_at=stop_at
        )
        for db, migrations in all_migrations.iteritems():
            for migration in migrations:
                migration_path = self._get_migration_path(db, migration)

                m, created = Migration.objects.using(db).get_or_create(
                    migration_label=os.path.split(migration)[-1],
                    content=open(migration_path, "rb").read()
                )
                if created:
                    # this might have been executed prior to committing
                    m.scm_version = self._get_rev(migration)
                    m.save()
                    print "%s:%s has been seeded" % (db, m.migration_label)
                else:
                    print "%s:%s was already applied" % (
                        db, m.migration_label
                    )
dataset/ETHPy150Open paltman-archive/nashvegas/nashvegas/management/commands/upgradedb.py/Command.seed_migrations