public function migrateUp(MigrationConfig $config, $flushDatabase = false)
	{
		$migrations = $this->instantiateMigrations($config);
		
		if(empty($migrations))
		{
			$skip = false;
		}
		else
		{
			$skip = $this->platform->hasTable('#__kk_migrations');
				
			if($skip)
			{
				$params = [];
				$in = [];
		
				$mtime = clone $this->date;
		
				foreach(array_values($migrations) as $i => $migration)
				{
					$in[] = ':v' . $i;
					$params['v' . $i] = $migration->getVersion();
					$date = new \DateTime('@' . filemtime((new \ReflectionClass(get_class($migration)))->getFileName()));
						
					if($date > $mtime)
					{
						$mtime = $date;
					}
				}
		
				$stmt = $this->conn->prepare(sprintf("SELECT COUNT(*) AS cnt, MAX(`migrated`) AS mtime FROM `#__kk_migrations` WHERE `version` IN (%s)", implode(', ', $in)));
				$stmt->bindAll($params);
				$stmt->execute();
		
				// Only skip migrations if all of them are alreay migrated up.
				$row = $stmt->fetchNextRow();
				$dbcnt = (int)$row['cnt'];
				$dbmtime = \DateTime::createFromFormat('YmdHis', $row['mtime']);
		
				$skip = (count($params) === $dbcnt) && ($dbmtime > $mtime);
			}
		}
		
		if(!$skip)
		{
			if($flushDatabase)
			{
				$this->platform->flushDatabase();
			}
				
			foreach($migrations as $migration)
			{
				$this->executeMigrationUp($migration);
			}
		}
		
		if($skip && $flushDatabase)
		{
			$this->platform->flushData();
		}
	}
public function migrateUp(MigrationConfig $config, $flushDatabase = false)
	{
		$migrations = $this->instantiateMigrations($config);
		
		if(empty($migrations))
		{
			$skip = false;
		}
		else
		{
			$skip = $this->platform->hasTable('#__kk_migrations');
				
			if($skip)
			{
				$params = [];
				$in = [];
		
				$mtime = clone $this->date;
		
				foreach(array_values($migrations) as $i => $migration)
				{
					$in[] = ':v' . $i;
					$params['v' . $i] = $migration->getVersion();
					$date = new \DateTime('@' . filemtime((new \ReflectionClass(get_class($migration)))->getFileName()));
						
					if($date > $mtime)
					{
						$mtime = $date;
					}
				}
		
				$stmt = $this->conn->prepare(sprintf("SELECT COUNT(*) AS cnt, MAX(`migrated`) AS mtime FROM `#__kk_migrations` WHERE `version` IN (%s)", implode(', ', $in)));
				$stmt->bindAll($params);
				$stmt->execute();
		
				// Only skip migrations if all of them are alreay migrated up.
				$row = $stmt->fetchNextRow();
				$dbcnt = (int)$row['cnt'];
				$dbmtime = \DateTime::createFromFormat('YmdHis', $row['mtime']);
		
				$skip = (count($params) === $dbcnt) && ($dbmtime > $mtime);
			}
		}
		
		if(!$skip)
		{
			if($flushDatabase)
			{
				$this->platform->flushDatabase();
			}
				
			foreach($migrations as $migration)
			{
				$this->executeMigrationUp($migration);
			}
		}
		
		if($skip && $flushDatabase)
		{
			$this->platform->flushData();
		}
	}
public function migrateUp ( MigrationConfig $ config , $ flushDatabase = false ) { $ migrations = $ this -> instantiateMigrations ( $ config ) ; if ( empty ( $ migrations ) ) { $ skip = false ; } else { $ skip = $ this -> platform -> hasTable ( '#__kk_migrations' ) ; if ( $ skip ) { $ params = [ ] ; $ in = [ ] ; $ mtime = clone $ this -> date ; foreach ( array_values ( $ migrations ) as $ i => $ migration ) { $ in [ ] = ':v' . $ i ; $ params [ 'v' . $ i ] = $ migration -> getVersion ( ) ; $ date = new \ DateTime ( '@' . filemtime ( ( new \ ReflectionClass ( get_class ( $ migration ) ) ) -> getFileName ( ) ) ) ; if ( $ date > $ mtime ) { $ mtime = $ date ; } } $ stmt = $ this -> conn -> prepare ( sprintf ( "SELECT COUNT(*) AS cnt, MAX(`migrated`) AS mtime FROM `#__kk_migrations` WHERE `version` IN (%s)" , implode ( ', ' , $ in ) ) ) ; $ stmt -> bindAll ( $ params ) ; $ stmt -> execute ( ) ; // Only skip migrations if all of them are alreay migrated up. $ row = $ stmt -> fetchNextRow ( ) ; $ dbcnt = ( int ) $ row [ 'cnt' ] ; $ dbmtime = \ DateTime :: createFromFormat ( 'YmdHis' , $ row [ 'mtime' ] ) ; $ skip = ( count ( $ params ) === $ dbcnt ) && ( $ dbmtime > $ mtime ) ; } } if ( ! $ skip ) { if ( $ flushDatabase ) { $ this -> platform -> flushDatabase ( ) ; } foreach ( $ migrations as $ migration ) { $ this -> executeMigrationUp ( $ migration ) ; } } if ( $ skip && $ flushDatabase ) { $ this -> platform -> flushData ( ) ; } }
Execute all up-migrations loaded from the given config.

DB will be flushed if a migration must be applied, will simply flush all data if no migration is needed.

@param MigrationConfig $config All configured migrations to be applied.
@param boolean $flushDatabase Flush database before any migration is applied?
Execute all up - migrations loaded from the given config .