public function migrateUp( $levels = NULL )
    {
        if ( NULL !== $levels )
        {
            $this->levels = $levels;
        }
        
        $newMigrations = $this->getNewMigrations( );
        
        $i = 0;
        
        if ( self::MIGRATE_ALL === $this->levels || $this->levels > count( $newMigrations ) )
        {
            $this->levels = count( $newMigrations );
        }
        
        while ( $i < $this->levels )
        {
            $class = $this->migrationNamespace . '\\' . $newMigrations[ $i ];
            
            if ( !class_exists( $class ) )
            {
                if ( !array_search( 'RawPHP\\RawMigrator\\Migrations\\', $this->namespaces, TRUE ) )
                {
                    $this->namespaces[] = 'RawPHP\\RawMigrator\\Migrations\\';
                }
                
                foreach( $this->namespaces as $ns )
                {
                    $cls = $ns . $newMigrations[ $i ];
                    
                    if ( class_exists( $cls ) )
                    {
                        $class = $cls;
                        
                        break;
                    }
                }
                
                if ( NULL === $class )
                {
                    throw new MigrationException( 'Migration class: ' . $class . ' - not found' );
                }
            }
            
            $migration = new $class( );
            
            $method = new \ReflectionMethod( $class, 'migrateUp' );
            
            // run migrateUp
            if ( $class === $method->getdeclaringClass()->name )
            {
                $migration->migrateUp( $this->db );
                
                $this->_addMigrationRecord( $class );
            }
            else
            {
                $method = new \ReflectionMethod( $class, 'safeMigrateUp' );
                
                if ( $class === $method->getDeclaringClass()->name )
                {
                    try
                    {
                        $this->db->startTransaction( );
                        
                        // turn off auto commit
                        $this->db->setTransactionAutocommit( FALSE );
                        
                        // run safeMigrateUp
                        $migration->safeMigrateUp( $this->db );
                        
                        // update migrations table with the new applied migration
                        $this->_addMigrationRecord( $class );
                        
                        // commit transaction
                        $this->db->commitTransaction( );
                    }
                    catch ( Exception $e )
                    {
                        // roleback transaction
                        $this->db->rollbackTransaction( );
                        
                        throw $e;
                    }
                }
            }
            
            $i++;
            
            if ( $this->levels === $i )
            {
                $this->doAction( self::ON_MIGRATE_UP_ACTION );
                
                return;
            }
        }
    }