diff --git a/install/ajax/process-migration.php b/install/ajax/process-migration.php new file mode 100644 index 00000000..4b92687d --- /dev/null +++ b/install/ajax/process-migration.php @@ -0,0 +1,37 @@ + "{$file} not found!", 500)); + } +}); + +require(HESK_PATH . 'install/migrations/core.php'); + +$allMigrations = getAllMigrations(); +$json = file_get_contents('php://input'); +$request = json_decode($json, true); + +/* @var $migration AbstractMigration */ +$migration = $allMigrations[$request['migrationNumber']]; + +if ($request['direction'] === 'up') { + $migration->up(); +} elseif ($request['direction'] === 'down') { + $migration->down(); +} else { + output(array("message" => "Invalid direction provided"), 400); +} + +function output($data, $response = 200) { + http_response_code($response); + header('Content-Type: application/json'); + print json_encode($data); +} \ No newline at end of file diff --git a/install/migrations/AbstractMigration.php b/install/migrations/AbstractMigration.php new file mode 100644 index 00000000..e8212ad2 --- /dev/null +++ b/install/migrations/AbstractMigration.php @@ -0,0 +1,7 @@ + null + 1 => new StatusesMigration() ); } \ No newline at end of file