migrates to the latest version unless -version is specified

@param string	name of the type (in case of app, it's 'default')
@param string	type (app, module or package)
@param string	direction of migration (up or down)
192417
protected static function _run($name, $type)
	{
		// -v or --version
		$version = \Cli::option('v', \Cli::option('version', ''));

		// version is used as a flag, so show it
		if ($version === true)
		{
			\Cli::write('Currently installed migrations for '.$type.':'.$name.':', 'green');

			foreach (\Config::get('migrations.version.'.$type.'.'.$name, array()) as $version)
			{
				\Cli::write('- '.$version);
			}
			return;
		}

		// version contains a timestamp of sorts
		elseif ($version !== '')
		{
			// if version has a value, make sure only 1 item was passed
			if (static::$default + static::$module_count + static::$package_count > 1)
			{
				\Cli::write('Migration: version only accepts 1 item.');
				return;
			}
			$migrations = \Migrate::version($version, $name, $type, \Cli::option('catchup', false));
		}

		// migrate to the latest version
		else
		{
			$migrations = \Migrate::latest($name, $type, \Cli::option('catchup', false));
		}

		// any migrations executed?
		if ($migrations)
		{
			\Cli::write('Performed migrations for '.$type.':'.$name.':', 'green');

			foreach ($migrations as $migration)
			{
				\Cli::write($migration);
			}
		}
		else
		{
			if ($migrations === false)
			{
				\Cli::write('Some migrations where skipped for '.$type.':'.$name.'. Please re-run the migrations.', 'cyan');
			}
			elseif ($version !== '')
			{
				\Cli::write('No migrations were found for '.$type.':'.$name.'.');
			}
			else
			{
				\Cli::write('Already on the latest migration for '.$type.':'.$name.'.');
			}
		}
	}
961476
protected static function _current($name, $type)
	{
		// -v or --version
		if (\Cli::option('v', \Cli::option('version', '')) !== '')
		{
			\Cli::write('You can not define a version when using the "current" command.', 'red');
		}

		$migrations = \Migrate::current($name, $type);

		if ($migrations)
		{
			\Cli::write('Newly installed migrations for '.$type.':'.$name.':', 'green');
			foreach ($migrations as $migration)
			{
				\Cli::write('- '.$migration);
			}
		}
		else
		{
			// migration is already on current version
			\Cli::write('Already on the current migration version for '.$type.':'.$name.'.');
		}
	}
665146
public function migrate(Extension $extension, $direction = 'up')
    {
        $this->app->bind('Illuminate\Database\Schema\Builder', function ($container) {
            return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder();
        });

        $extension->migrate($this->migrator, $direction);
    }
402960
private function migrateAll(string $migrationFile, string $name, string $action)
  {
    $title =  substr($migrationFile, 0, -4);
    $migration = Migration::where('title', $title)->first();

    if (strtolower($action == 'drop' ? 'down' : $action) == 'down') {
      if ($migration != null) {
        try {
          call_user_func([$name, 'down']);
        }
        catch (Exception $e) {
          Log::error($e);
          return '<error>Couldn\'t migrate. See log for more information</error>';
        }

        $migration->delete();
        return '<info>Migration was successful</info>';
      }
      else {
        return 0;
      }
    }
    else if (strtolower($action) == 'up'){
      if ($migration == null) {
        try {
          call_user_func([$name, 'up']);
        }
        catch (Exception $e) {
          Log::error($e);
          return '<error>Couldn\'t migrate. See log for more information</error>';
        }

        Migration::create([
          'title' => $title
        ]);

        return '<info>Migration was successful</info>';
      }
      else {
        return 0;
      }
    }
  }
768125
public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false)
    {
        $installer = new Installer($name, $version, $type, $subtree);

        return $installer->run();
    }
271149
public function addType(string $name, string $type): void{
        $this->types[$name] = new Type($type);
    }
1345652
private function bakeDatabaseConfig(string $name) : void
    {
        $options = [
            'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'db' . DS,
            'ext' => 'json'
        ];

        $this->bake('migration.dist', 'Module/db/migration', [], '', $options);
    }
644761
protected static function runMigrations($project, $config=[], $method='up', $type='master')
    {
        /** @var \LCI\MODX\Console\Console $console */
        $console = new Console();
        static::$modx = $console->loadMODX();

        // 1. install BLend
        $handler = new VoidUserInteractionHandler();

        $blender = new Blender(static::$modx, $handler, $config);

        if (!$blender->isBlendInstalledInModx()) {
            $blender->install();
        }

        $blender->setProject($project);

        // 2. run Migrations
        $blender->runMigration($method, $type);
    }
1028946
public void updateUpdate(String type, String location) throws SecurityException {
	checkWriteAccess();

	if (!(config instanceof ConfigServer)) {
	    throw new SecurityException("can't change update setting from this context, access is denied");
	}
	Element update = _getRootElement("update");
	update.setAttribute("type", type);
	try {
	    location = HTTPUtil.toURL(location, true).toString();
	}
	catch (Throwable e) {
	    ExceptionUtil.rethrowIfNecessary(e);
	}
	update.setAttribute("location", location);
    }
288179
public function buildFieldMigrationForTable($name, $type, $indexed, $tableName)
    {
        $path = $this->getMigrationPath($tableName, $name);
        $migration = $this->getTableFieldMigrationName($name, $tableName);

        $contents = view('_hierarchy::migrations.field', [
            'field'     => $name,
            'table'     => source_table_name($tableName),
            'migration' => $migration,
            'type'      => $this->getColumnType($type),
            'indexed'   => $indexed
        ])->render();

        $this->write($path, $contents);

        return $this->getMigrationClassPath($migration);
    }
692345
public function install($name, $version = null, $migrate = true, $seed = true, $publish = true)
    {
        // Check if already installed
        if ($this->installed($name)) {
            throw new Exceptions\HookAlreadyInstalledException("Hook [{$name}] is already installed.");
        }

        event(new Events\InstallingHook($name));

        // Prepare a repository if the hook is located locally
        if ($this->local($name)) {
            $this->prepareLocalInstallation($name);

            if (is_null($version)) {
                $version = static::$localVersion;
            }
        }

        // Require hook
        if (is_null($version)) {
            $this->composerRequire([$name]); // TODO: Save Composer output somewhere
        } else {
            $this->composerRequire([$name.':'.$version]); // TODO: Save Composer output somewhere
        }

        // TODO: Handle the case when Composer outputs:
        // Your requirements could not be resolved to an installable set of packages.
        //
        //      Problem 1
        //        - The requested package composer-github-hook v0.0.1 exists as composer-github-hook[dev-master]
        //          but these are rejected by your constraint.

        // TODO: Move to Composer Plugin
        $this->readJsonFile([$name]);
        $this->remakeJson();

        if ($migrate) {
            $this->migrateHook($this->hooks[$name]);
        }

        if ($seed) {
            $this->seedHook($this->hooks[$name]);
        }

        if ($publish) {
            $this->publishHook($this->hooks[$name]);
        }

        event(new Events\InstalledHook($this->hooks[$name]));
    }
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
384761
public function migrateToVersion($version, $up = true)
    {
        $this->createIfNotExists();
        $currentVersion = $this->getCurrentVersion();
        if ($up) {
            $this->up($version);
        } else {
            $this->down($version);
        }
    }
1100796
@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		ApptentiveLog.d(DATABASE, "Upgrade database from %d to %d", oldVersion, newVersion);
		try {
			DatabaseMigrator migrator = createDatabaseMigrator(oldVersion, newVersion);
			if (migrator != null) {
				migrator.onUpgrade(db, oldVersion, newVersion);
			}
		} catch (Exception e) {
			ApptentiveLog.e(DATABASE, e, "Exception while trying to migrate database from %d to %d", oldVersion, newVersion);
			logException(e);

			// if migration failed - create new table
			db.execSQL(SQL_DELETE_PAYLOAD_TABLE);
			onCreate(db);
		}
	}
1163485
def migrate(direction)
      return unless respond_to?(direction)

      case direction
      when :up   then announce_migration "migrating"
      when :down then announce_migration "reverting"
      end

      time = Benchmark.measure { send(direction) }

      case direction
      when :up   then announce_migration "migrated (%.4fs)" % time.real; puts
      when :down then announce_migration "reverted (%.4fs)" % time.real; puts
      end
    end
995504
public function buildField($name, $type, $indexed, $tableName, NodeTypeContract $nodeType)
    {
        $this->modelBuilder->build($tableName, $nodeType->getFields());
        $this->buildForm($nodeType);
        $migration = $this->migrationBuilder->buildFieldMigrationForTable($name, $type, $indexed, $tableName);

        $this->migrateUp($migration);
    }
455588
public function migrate($direction = 'up')
    {
        if (!$this->tableExists('schema_migrations')) {
            $this->createMigrationsTable();
        }

        foreach (get_declared_classes() as $declaredClass) {
            if (is_subclass_of($declaredClass, "Avalon\\Database\\Migration")) {
                if ($direction === 'up') {
                    $this->up($declaredClass);
                } elseif ($direction === 'down') {
                    $this->down($declaredClass);
                }
            }
        }
    }