You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
881 B
PHP
31 lines
881 B
PHP
<?php
|
|
define('IN_SCRIPT', 1);
|
|
define('HESK_PATH', '../../');
|
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
|
require(HESK_PATH . 'inc/common.inc.php');
|
|
hesk_load_database_functions();
|
|
|
|
|
|
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']];
|
|
|
|
hesk_dbConnect();
|
|
if ($request['direction'] === 'up') {
|
|
$migration->up($hesk_settings);
|
|
} elseif ($request['direction'] === 'down') {
|
|
$migration->down($hesk_settings);
|
|
} else {
|
|
output(array("message" => "Invalid direction provided"), 400);
|
|
}
|
|
|
|
function output($data, $response = 200, $header = "Content-Type: application/json") {
|
|
http_response_code($response);
|
|
header($header);
|
|
print json_encode($data);
|
|
} |