system/Database/Migrations/Migrations.php
/**
     * Run all application's migrations
     *
     * @return void
     */
Run all application's migrations
@return void
Run all application ' s migrations @return void
public static function RunGroupedMigrations() {
        self::$db = self::connect();
        $migration_files = array();
        $scanned_files = scandir(self::$dir);
        if (empty($scanned_files)) {
            echo "\e[0;33;40mNo grouped migrations found!\e[0m\n";
            return;
        }
        $file_count = count($scanned_files);
        for ($f = 0; $f < $file_count; $f++) {
            if (preg_match('/^.*\.(sql|json|csv|xml)$/i', $scanned_files[$f]) === 1) {
                $migration_files[] = $scanned_files[$f];
            }
        }
        $all_files = count($migration_files);
        echo "\e[0;33;40mRunning grouped migrations...\e[0m\n";
        $migration_exists = 0;
        for ($i = 0; $i < $all_files; $i++) {
            $migration_file_name = substr($migration_files[$i], 0, strlen($migration_files[$i]) - 4);
            if (self::checkMigrations($migration_file_name))
            {
                $migration_exists += 1;
                continue;
            }
            try {
                $query = file_get_contents(self::$dir.$migration_files[$i]);
                $stmt = self::$db->prepare($query);
                $stmt->execute();
                if(self::storeMigration($migration_file_name))
                {
                    echo "\e[0;32;40mMigrated: \e[0m" . $migration_file_name;
                }else {
                    echo "\e[0;33;40mFailed to Migrate: \e[0m" . $migration_file_name;
                }
            }catch (PDOException $e) {
                self::logError($e->getMessage());
                echo "\e[0;33;40mFailed to Migrate: \e[0m" . $migration_file_name . "\n";
                echo "\e[0;33;40mRun migrate:logs to view error logs. \n";
            }
        }
        if($migration_exists == $all_files)
        {
            echo "\e[0;33;40mNothing to migrate! \e[0m \n";
        }
    }
public static function RunGroupedMigrations ( ) { self :: $ db = self :: connect ( ) ; $ migration_files = array ( ) ; $ scanned_files = scandir ( self :: $ dir ) ; if ( empty ( $ scanned_files ) ) { echo " \e [0;33;40mNo grouped migrations found! \e [0m \n " ; return ; } $ file_count = count ( $ scanned_files ) ; for ( $ f = 0 ; $ f < $ file_count ; $ f ++ ) { if ( preg_match ( '/^.*\.(sql|json|csv|xml)$/i' , $ scanned_files [ $ f ] ) === 1 ) { $ migration_files [ ] = $ scanned_files [ $ f ] ; } } $ all_files = count ( $ migration_files ) ; echo " \e [0;33;40mRunning grouped migrations... \e [0m \n " ; $ migration_exists = 0 ; for ( $ i = 0 ; $ i < $ all_files ; $ i ++ ) { $ migration_file_name = substr ( $ migration_files [ $ i ] , 0 , strlen ( $ migration_files [ $ i ] ) - 4 ) ; if ( self :: checkMigrations ( $ migration_file_name ) ) { $ migration_exists += 1 ; continue ; } try { $ query = file_get_contents ( self :: $ dir . $ migration_files [ $ i ] ) ; $ stmt = self :: $ db -> prepare ( $ query ) ; $ stmt -> execute ( ) ; if ( self :: storeMigration ( $ migration_file_name ) ) { echo " \e [0;32;40mMigrated:  \e [0m " . $ migration_file_name ; } else { echo " \e [0;33;40mFailed to Migrate:  \e [0m " . $ migration_file_name ; } } catch ( PDOException $ e ) { self :: logError ( $ e -> getMessage ( ) ) ; echo " \e [0;33;40mFailed to Migrate:  \e [0m " . $ migration_file_name . " \n " ; echo " \e [0;33;40mRun migrate:logs to view error logs.  \n " ; } } if ( $ migration_exists == $ all_files ) { echo " \e [0;33;40mNothing to migrate!  \e [0m  \n " ; } }
Run all application's migrations
 @return void
Run all application ' s migrations @return void