| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/WPCAFE/wp-content/plugins/wp-cafe/base/database/ |
Upload File : |
<?php
namespace WpCafe\Database;
/**
* MigrationRunner class.
*
* Responsible for running and rolling back all migration files.
*/
class Migration_Runner {
/**
* Run all migration files to apply the database schema changes.
*
* This method loads all PHP files inside the migrations directory,
* instantiates the migration class, and calls the up() method.
*
* @return void
*/
public static function migrate() {
$migration_files = glob( wpcafe()->plugin_directory . '/migrations/*.php' );
if ( ! is_array( $migration_files ) ) {
return;
}
foreach ( $migration_files as $file ) {
$migration = require_once $file;
if ( $migration instanceof Migration ) {
$migration->up();
}
}
}
/**
* Rollback all migration files to revert the database schema changes.
*
* This method loads all PHP files inside the migrations directory in reverse order,
* instantiates the migration class, and calls the down() method.
*
* @return void
*/
public static function rollback() {
$migration_files = glob( wpcafe()->plugin_directory . '/migrations/*.php' );
if ( ! is_array( $migration_files ) ) {
return;
}
foreach ( array_reverse( $migration_files ) as $file ) {
$migration = require_once $file;
if ( $migration instanceof Migration ) {
$migration->down();
}
}
}
}