src/bundles/Database/Migrator.php
public static function rollback()
	{
		// first of all we have to filter only the already migrated versions
		$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] );
				}
			}
		}
		
		$revisions = array();
		
		foreach( $available as $key => $value )
		{
			if ( empty( $value ) )
			{
				continue;
			}
			
			foreach( $value as $name => $path )
			{
				$revisions[$name.'::'.$key] = $path;
			}
		}
		
		// nothing to rollback?
		if ( empty( $revisions ) )
		{
			if ( \ClanCats::is_cli() )
			{
				\CCCli::warning( 'nothing to rollback to.' );
			}
			
			return false;
		}
		
		ksort( $revisions );
		
		end( $revisions ); 
		list( $time, $key ) = explode( '::', key( $revisions ) );
		
		$migration = new static( array_pop( $revisions ) );
		
		// rollback the migration
		$migration->down();
		
		// get the lastet migration from the group
		$others = \CCArr::get( $key, $available );
		
		ksort( $others );
		array_pop( $others );
		end( $others );
		
		// update the config
		static::$config->set( $key.'.revision', key( $others ) );
		static::$config->write();
		
		return true;
	}
public static function rollback()
	{
		// first of all we have to filter only the already migrated versions
		$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] );
				}
			}
		}
		
		$revisions = array();
		
		foreach( $available as $key => $value )
		{
			if ( empty( $value ) )
			{
				continue;
			}
			
			foreach( $value as $name => $path )
			{
				$revisions[$name.'::'.$key] = $path;
			}
		}
		
		// nothing to rollback?
		if ( empty( $revisions ) )
		{
			if ( \ClanCats::is_cli() )
			{
				\CCCli::warning( 'nothing to rollback to.' );
			}
			
			return false;
		}
		
		ksort( $revisions );
		
		end( $revisions ); 
		list( $time, $key ) = explode( '::', key( $revisions ) );
		
		$migration = new static( array_pop( $revisions ) );
		
		// rollback the migration
		$migration->down();
		
		// get the lastet migration from the group
		$others = \CCArr::get( $key, $available );
		
		ksort( $others );
		array_pop( $others );
		end( $others );
		
		// update the config
		static::$config->set( $key.'.revision', key( $others ) );
		static::$config->write();
		
		return true;
	}
public static function rollback ( ) { // first of all we have to filter only the already migrated versions $ 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 ] ) ; } } } $ revisions = array ( ) ; foreach ( $ available as $ key => $ value ) { if ( empty ( $ value ) ) { continue ; } foreach ( $ value as $ name => $ path ) { $ revisions [ $ name . '::' . $ key ] = $ path ; } } // nothing to rollback? if ( empty ( $ revisions ) ) { if ( \ ClanCats :: is_cli ( ) ) { \ CCCli :: warning ( 'nothing to rollback to.' ) ; } return false ; } ksort ( $ revisions ) ; end ( $ revisions ) ; list ( $ time , $ key ) = explode ( '::' , key ( $ revisions ) ) ; $ migration = new static ( array_pop ( $ revisions ) ) ; // rollback the migration $ migration -> down ( ) ; // get the lastet migration from the group $ others = \ CCArr :: get ( $ key , $ available ) ; ksort ( $ others ) ; array_pop ( $ others ) ; end ( $ others ) ; // update the config static :: $ config -> set ( $ key . '.revision' , key ( $ others ) ) ; static :: $ config -> write ( ) ; return true ; }
Revert the last migration

@return void
Revert the last migration