/*
Check if some classes need migration
return: true if all classes are up-to-date, else false
165031
public function check()
    {
        foreach($this->classes as $class) {
            $ret = $this->_check($class);
            if ($ret === false) {
                echo 'Database need migration' . PHP_EOL;
                break;
            }
        }

        return $ret;
    }
601483
public function isUpdateRequired(): bool
    {
        $history = $this->fetchHistory();

        if (!empty($history)) {
            $this->setDummyMigrationClass();

            foreach ($history as $migration => $time) {
                $migration = trim($migration, '\\');
                if (in_array($migration, $this->skipMigrations, true)) {
                    continue;
                }

                if (!$this->gatherChanges($this->extract($migration))) {
                    break;
                }
            }

            return $this->compareStructures();
        }

        return true;
    }
891669
def migration_filters(klass)
      # the attribute => migration method hash
      mh = attribute_method_hash(klass)
      @mgt_mths[klass] = mh unless mh.empty?
      fh = attribute_filter_hash(klass)
      return if mh.empty? and fh.empty?
      # For each class path terminal attribute metadata, add the migration filters
      # to the attribute metadata => proc hash.
      klass.attributes.to_compact_hash do |pa|
        # the filter
        flt = fh[pa]
        # the migration shim method
        mth = mh[pa]
        # the filter proc
        Proc.new do |obj, value, row|
          # filter the value
          value = flt.transform(value) if flt and not value.nil?
          # apply the migrate_<attribute> method, if defined
          if mth then
            obj.send(mth, value, row) unless value.nil?
          else
            value
          end
        end
      end
    end
1323449
def exec_migration(migration, is_up)
      migration_dir = self.migration_dir(migration)
      result = @lang.exec_migration(migration_dir, is_up)
      if @lang.ext != "sql"
        puts result
      end

      Log.info("Updating current version number...")
      version = migration["version"]
      is_up ? @db.log_up(version) : @db.log_down(version)
    end
1331758
private static boolean isSupportedClass(Class<?> clazz) {
        return Observable.class.isAssignableFrom(clazz) ||
               Maybe.class.isAssignableFrom(clazz) ||
               Single.class.isAssignableFrom(clazz) ||
               Completable.class.isAssignableFrom(clazz);
    }
709021
public function _perform($class)
    {
        $version = ObjectVersion::get($class);
        echo 'Object ' . $class . ' is in version ' . $version . PHP_EOL;

        while (true) {
            $migrateFunction = 'migrate_' . $version . '_' . ($version + 1);
            if (method_exists($class, $migrateFunction) === false) {
                break;
            }

            echo 'Migrate from ' . $version . ' to ' . ($version + 1) . PHP_EOL;
            $ok = forward_static_call(array($class, $migrateFunction));
            if ($ok !== true) {
                echo 'Failed' . PHP_EOL;
                break;
            }

            $version = ObjectVersion::inc($class);
            echo 'Ok' . PHP_EOL;
        }
    }
187603
public function validatePrerequisites() {
        try {
            Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
            return true;
        }
        catch (\Exception $ex) { }
        return false;
    }
1260297
public function isVersioningService()
    {
        $schema = $this->utils->getCurrentSchema();
        if (isset($schema->{'x-versioning'}) && $schema->{'x-versioning'} === true) {
            return true;
        }
        return false;
    }
209959
def is_existing_up_to_date(destination, latest_version):
    """"""
    version_path = os.path.join(
        destination, 'google_appengine', 'VERSION')

    if not os.path.exists(version_path):
        return False

    with open(version_path, 'r') as f:
        version_line = f.readline()

        match = SDK_RELEASE_RE.match(version_line)

        if not match:
            print('Unable to parse version from:', version_line)
            return False

        version = [int(x) for x in match.groups()]

    return version >= latest_version
1208244
private function isDatabaseAlreadyMigrated()
    {
        if (!is_null($this->isDatabaseAlreadyMigrated)) {
            return $this->isDatabaseAlreadyMigrated;
        }

        return ($this->isDatabaseAlreadyMigrated = Schema::hasTable('squanto_lines'));
    }
858429
def run(*migration_classes)
      opts = migration_classes.extract_options!
      dir = opts[:direction] || :up
      dir = (dir == :down ? :up : :down) if opts[:revert]
      if reverting?
        # If in revert and going :up, say, we want to execute :down without reverting, so
        revert { run(*migration_classes, direction: dir, revert: true) }
      else
        migration_classes.each do |migration_class|
          migration_class.new.exec_migration(connection, dir)
        end
      end
    end
1183903
protected function alreadyExecutedMigrations()
    {
        $results = $this->db->query(
            'SELECT * FROM `app_migrations`',
            DbAdapter::QUERY_MODE_EXECUTE
        );

        return (array) iterator_to_array($results, true);
    }
1321373
function() {
    return !!(_flashState.sandboxed || _flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
  }
1054845
public function validatePrerequisites() {
        try {
            Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
            
            return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
        }
        catch (\Exception $ex) {  }
        return false;
    }
714091
protected function checkLessonsMigrationState()
    {
        $this->output->info('# Checkin lessons migration state... #');

        switch ($this->checkLessonMigrationStats()) {
            case 0:
                return true;
            case 1:
                $this->output->error(' Migration stats does not match!');
                if ($this->output->confirm('Do you wish to continue (lesson_migration and scool lesson tables will be truncated)?')) {
                    DB::connection('ebre_escool')->statement('DELETE FROM lesson_migration');
                    DB::connection('ebre_escool')->statement('ALTER TABLE lesson_migration AUTO_INCREMENT = 1');
                    DB::statement('DELETE FROM lessons');
                    DB::statement('ALTER TABLE lessons AUTO_INCREMENT = 1');
                    DB::statement('DELETE FROM lesson_user');
                    DB::statement('ALTER TABLE lesson_user AUTO_INCREMENT = 1');
                    DB::statement('DELETE FROM lesson_submodule');
                    DB::statement('ALTER TABLE lesson_submodule AUTO_INCREMENT = 1');
                    DB::statement('DELETE FROM classroom_submodule');
                    DB::statement('ALTER TABLE classroom_submodule AUTO_INCREMENT = 1');
                } else {
                    die();
                }
                return true;
            case 2:
                $this->output->info(' Lesson data seems already migrated. Skipping lessons migration...');
                return false;
        }
    }
978981
def is_backup_class(cls):
    """"""
    return True if (
        isclass(cls) and
        issubclass(cls, Storable) and
        get_mapping(cls, no_mapping_ok=True)
    ) else False
318314
public function alreadyUpdated()
    {
        $migrations = $this->getMigrations();
        $dbMigrations = $this->getExecutedMigrations();

        // If the count of migrations and dbMigrations is equal,
        // then the update as already been updated.
        if (count($migrations) == count($dbMigrations)) {
            return true;
        }

        // Continue, the app needs an update
        return false;
    }