Returns a tuple of unapplied, current

        "Unapplied" is a list of unapplied migrations. "Current" is a list of the current migration
        states for apps with unapplied migrations.

        Both are tuples of the form (app, migration_name).
517655
def list_migrations(self):
        
        connection = connections[self._database_name]
        loader = MigrationLoader(connection, ignore_no_migrations=True)
        unapplied = self._get_unapplied_migrations(loader)
        currents = self._get_current_migration_state(loader, [u[0] for u in unapplied])
        return unapplied, currents
585444
public static function unstaged()
	{
		$available = static::available();
		
		foreach( $available as $key => $migrations )
		{
			foreach( $migrations as $time => $migration )
			{
				if ( $time <= static::$config->get( $key.'.revision', 0 ) )
				{
					unset( $available[$key][$time] );
				}
			}
		}
		
		return $available;
	}
688919
def migrate(self, migrations_package_name, up_to=9999):
        '''
        
        '''
        from .migrations import MigrationHistory
        logger = logging.getLogger('migrations')
        applied_migrations = self._get_applied_migrations(migrations_package_name)
        modules = import_submodules(migrations_package_name)
        unapplied_migrations = set(modules.keys()) - applied_migrations
        for name in sorted(unapplied_migrations):
            logger.info('Applying migration %s...', name)
            for operation in modules[name].operations:
                operation.apply(self)
            self.insert([MigrationHistory(package_name=migrations_package_name, module_name=name, applied=datetime.date.today())])
            if int(name[:4]) >= up_to:
                break
692376
static function getSubscribedEvents()
	{
		return [
			MigrationManager::EVENT_INIT_SERVICE           => 'update',
			MigrationManager::EVENT_ASK_MIGRATION_LIST     => 'update',
			MigrationManager::EVENT_ASK_MIGRATION_APPEND   => 'update',
			MigrationManager::EVENT_ASK_MIGRATION_ROLLBACK => 'update',
			MigrationManager::EVENT_FREE_SERVICE           => 'update',
		];
	}
722569
def run_migration_list(self, path, migrations, pretend=False):
        
        if not migrations:
            self._note("<info>Nothing to migrate</info>")

            return

        batch = self._repository.get_next_batch_number()

        for f in migrations:
            self._run_up(path, f, batch, pretend)
469718
public function status()
    {
        $connection = $this->getDI()->get($this->migrationAdapter);

        $lastMig = $connection->fetchOne('SELECT * FROM migration ORDER BY id DESC', \PDO::FETCH_ASSOC);

        print PHP_EOL . Color::info('Current Version : ' . $lastMig['version']) . PHP_EOL;
    }
836535
def init_or_migrate(self):
        
        assure_migrations_table_setup(self.session)

        # Find out what migration number, if any, this database data is at,
        # and what the latest is.
        migration_number = self.database_current_migration

        # Is this our first time?  Is there even a table entry for
        # this identifier?
        # If so:
        #  - create all tables
        #  - create record in migrations registry
        #  - print / inform the user
        #  - return 'inited'
        if migration_number is None:
            self.printer(u"-> Initializing %s... " % self.name_for_printing())

            self.init_tables()
            # auto-set at latest migration number
            self.create_new_migration_record()

            self.printer(u"done.\n")
            self.set_current_migration()
            return u'inited'

        # Run migrations, if appropriate.
        migrations_to_run = self.migrations_to_run()
        if migrations_to_run:
            self.printer(
                u'-> Updating %s:\n' % self.name_for_printing())
            for migration_number, migration_func in migrations_to_run:
                self.printer(
                    u'   + Running migration %s, "%s"... ' % (
                        migration_number, migration_func.func_name))
                migration_func(self.session)
                self.printer('done.\n')

            self.set_current_migration()
            return u'migrated'

        # Otherwise return None.  Well it would do this anyway, but
        # for clarity... ;)
        return None
472104
def get_pending_migrations(path, databases=None, stop_at=None):
    
    if stop_at is None:
        stop_at = float("inf")
    
    # database: [(number, full_path)]
    possible_migrations = get_all_migrations(path, databases)
    # database: [full_path]
    applied_migrations = get_applied_migrations(databases)
    # database: [full_path]
    to_execute = defaultdict(list)
    
    for database, scripts in possible_migrations.iteritems():
        applied = applied_migrations[database]
        pending = to_execute[database]
        for number, migration in scripts:
            path, script = os.path.split(migration)
            if script not in applied and number <= stop_at:
                pending.append(script)
    
    return dict((k, v) for k, v in to_execute.iteritems() if v)
401863
public function actionMigrations()
    {
        $migrator = Craft::$app->getContentMigrator();
        $pending = $migrator->getNewMigrations();
        $applied = $migrator->getMigrationHistory();
        return $this->renderTemplate('migrationmanager/migrations', array('pending' => $pending, 'applied' => $applied));
    }
773645
function getCurrentApplication() {
        $url = \CharlotteDunois\Yasmin\HTTP\APIEndpoints::ENDPOINTS['currentOAuthApplication'];
        return $this->api->makeRequest('GET', $url, array());
    }
828343
def sorted_migrations(self):
        
        if not self._sorted_migrations:
            self._sorted_migrations = sorted(
                self.migration_registry.items(),
                # sort on the key... the migration number
                key=lambda migration_tuple: migration_tuple[0])

        return self._sorted_migrations
1169952
def check_migrations_applied(app_configs, **kwargs):
    
    from django.db.migrations.loader import MigrationLoader
    errors = []

    # Load migrations from disk/DB
    try:
        loader = MigrationLoader(connection, ignore_no_migrations=True)
    except (ImproperlyConfigured, ProgrammingError, OperationalError):
        msg = "Can't connect to database to check migrations"
        return [checks.Info(msg, id=health.INFO_CANT_CHECK_MIGRATIONS)]

    if app_configs:
        app_labels = [app.label for app in app_configs]
    else:
        app_labels = loader.migrated_apps

    for node, migration in loader.graph.nodes.items():
        if migration.app_label not in app_labels:
            continue
        if node not in loader.applied_migrations:
            msg = 'Unapplied migration {}'.format(migration)
            # NB: This *must* be a Warning, not an Error, because Errors
            # prevent migrations from being run.
            errors.append(checks.Warning(msg,
                                         id=health.WARNING_UNAPPLIED_MIGRATION))

    return errors
1026772
def exec_migrations(is_up=true)
      Log.info("Executing migrations...")
      migrations = yield @db.current_version

      if migrations.count == 0
        Log.warn("Migrations not found")
        return
      end

      migrations.each do |migration|
        self.exec_migration(migration, is_up)
      end
      Log.success("Migrations executed. Current version: #{@db.current_version}")
    end
681401
public function getNewMigrations( )
    {
        // check if migration table exists
        $exists = $this->db->tableExists( $this->migrationTable );
        
        if ( !$exists )
        {
            $this->createMigrationTable( );
        }
        
        $query = "SELECT * FROM $this->migrationTable";
        
        $applied = $this->db->query( $query );
        
        $migrations = $this->getMigrations();
        
        $list = array();
        
        foreach( $migrations as $migration )
        {
            $done = FALSE;
            $migToFind = NULL;
            
            foreach( $this->namespaces as $ns )
            {
                $cls = $ns . $migration;
                
                if ( class_exists( $cls ) )
                {
                    $migToFind = $cls;
                    
                    break;
                }
            }
            
            foreach( $applied as $mig )
            {
                if ( $mig[ 'migration_name' ] === $migToFind )
                {
                    $done = TRUE;
                    break;
                }
            }
            
            if ( !$done )
            {
                $list[] = $migration;
            }
        }
        
        return $this->filter( self::ON_GET_NEW_MIGRATIONS_FILTER, $list );
    }
1054819
@GET
    @Path("{uuid}")// uuid or dbName
    public Response migrateView(@PathParam("uuid") String uuid) {
        try {
            MigrationFeature.checkMigrationId(uuid);
        } catch (NotFoundException e) {
            Flyway flyway = locator.getService(Flyway.class, uuid);
            if (flyway == null)
                throw new NotFoundException();
            return Response.ok(flyway.info().all()).build();
        }

        Map<String, Migration> migrations = getMigrations();
        Map<String, String> model = buildPageModel(MigrationType.MIGRATE, uuid);

        String desc = model.get("description")
                .concat("&nbsp; - &nbsp;<input name=\"description\" placeholder=\"" +
                        Messages.get("view.app.database.migrate.description.placeholder")
                        + "\">");
        model.put("description", desc);

        StringBuilder tabs = new StringBuilder();
        StringBuilder diffs = new StringBuilder();

        StrSubstitutor sub = new StrSubstitutor(model);
        int i = 0;
        for (String dbName : migrations.keySet()) {
            Migration migration = migrations.get(dbName);
            ScriptInfo info = migration.generate();
            Flyway flyway = locator.getService(Flyway.class, dbName);
            boolean hasTable;
            try (Connection connection = flyway.getDataSource().getConnection()) {
                hasTable = connection.getMetaData().getTables(null, null, flyway.getTable(), null).next();
            } catch (SQLException e) {
                throw new AmebaException(e);
            }

            tabs.append("<li i=\"").append(i).append("\" class=\"db-name\">").append(dbName).append("</li>");
            diffs.append("<div class=\"diff\"><h2>");
            if (hasTable) {
                diffs.append(Messages.get("view.app.database.migrate.subTitle"));
            } else {
                diffs.append(Messages.get("view.app.database.migrate.baseline.subTitle"));
            }
            diffs.append("</h2><pre>")
                    .append(info.getApplyDdl())
                    .append("</pre></div>");
            i++;
        }
        model.put("dbNames", tabs.toString());
        model.put("diffs", diffs.toString());

        return Response.ok(sub.replace(MIGRATION_HTML))
                .type(MediaType.TEXT_HTML_TYPE)
                .build();
    }
563814
public function getCurrentVersion()
    {
        // We don't cache this code as the current version is pretty volatile.
        // TODO - that means they're no point in a setter then?
        // maybe we should cache and call a reset() method every time a migration is run
        $versions = $this->getVersions();
        $version = 0;

        if (!empty($versions)) {
            $version = end($versions);
        }

        $this->setCurrentVersion($version);

        return $this->currentVersion;
    }
1200646
public function getMigrationsToRun()
    {
        $allMigrations = $this->getAllMigrations();

        $ranMigrations = $this->getRanMigrations();

        return array_diff($allMigrations, $ranMigrations);
    }