fuel/fuel/core/classes/migrate.php
public static function version($version = null, $name = 'default', $type = 'app', $all = false)
	{
		// get the current version from the config
		$all or $current = \Config::get('migrations.version.'.$type.'.'.$name);

		// any migrations defined?
		if ( ! empty($current))
		{
			// get the timestamp of the last installed migration
			if (preg_match('/^(.*?)_(.*)$/', end($current), $match))
			{
				// determine the direction
				$direction = (is_null($version) or $match[1] < $version) ? 'up' : 'down';

				// fetch the migrations
				if ($direction == 'up')
				{
					$migrations = static::find_migrations($name, $type, $match[1], $version);
				}
				else
				{
					$migrations = static::find_migrations($name, $type, $version, $match[1], $direction);

					// we're going down, so reverse the order of mygrations
					$migrations = array_reverse($migrations, true);
				}

				// run migrations from current version to given version
				return static::run($migrations, $name, $type, $direction);
			}
			else
			{
				throw new \UnexpectedValueException('Could not determine a valid version from '.$current.'.');
			}
		}

		// run migrations from the beginning to given version
		return static::run(static::find_migrations($name, $type, null, $version), $name, $type, 'up');
	}
public static function version($version = null, $name = 'default', $type = 'app', $all = false)
	{
		// get the current version from the config
		$all or $current = \Config::get('migrations.version.'.$type.'.'.$name);

		// any migrations defined?
		if ( ! empty($current))
		{
			// get the timestamp of the last installed migration
			if (preg_match('/^(.*?)_(.*)$/', end($current), $match))
			{
				// determine the direction
				$direction = (is_null($version) or $match[1] < $version) ? 'up' : 'down';

				// fetch the migrations
				if ($direction == 'up')
				{
					$migrations = static::find_migrations($name, $type, $match[1], $version);
				}
				else
				{
					$migrations = static::find_migrations($name, $type, $version, $match[1], $direction);

					// we're going down, so reverse the order of mygrations
					$migrations = array_reverse($migrations, true);
				}

				// run migrations from current version to given version
				return static::run($migrations, $name, $type, $direction);
			}
			else
			{
				throw new \UnexpectedValueException('Could not determine a valid version from '.$current.'.');
			}
		}

		// run migrations from the beginning to given version
		return static::run(static::find_migrations($name, $type, null, $version), $name, $type, 'up');
	}
public static function version ( $ version = null , $ name = 'default' , $ type = 'app' , $ all = false ) { // get the current version from the config $ all or $ current = \ Config :: get ( 'migrations.version.' . $ type . '.' . $ name ) ; // any migrations defined? if ( ! empty ( $ current ) ) { // get the timestamp of the last installed migration if ( preg_match ( '/^(.*?)_(.*)$/' , end ( $ current ) , $ match ) ) { // determine the direction $ direction = ( is_null ( $ version ) or $ match [ 1 ] < $ version ) ? 'up' : 'down' ; // fetch the migrations if ( $ direction == 'up' ) { $ migrations = static :: find_migrations ( $ name , $ type , $ match [ 1 ] , $ version ) ; } else { $ migrations = static :: find_migrations ( $ name , $ type , $ version , $ match [ 1 ] , $ direction ) ; // we're going down, so reverse the order of mygrations $ migrations = array_reverse ( $ migrations , true ) ; } // run migrations from current version to given version return static :: run ( $ migrations , $ name , $ type , $ direction ) ; } else { throw new \ UnexpectedValueException ( 'Could not determine a valid version from ' . $ current . '.' ) ; } } // run migrations from the beginning to given version return static :: run ( static :: find_migrations ( $ name , $ type , null , $ version ) , $ name , $ type , 'up' ) ; }
migrate to a specific version, range of versions, or all

@param   mixed	version to migrate to (up or down!)
@param   string  name of the package, module or app
@param   string  type of migration (package, module or app)
@param	bool	if true, also run out-of-sequence migrations

@throws	UnexpectedValueException
@return	array
migrate to a specific version range of versions or all