MicroFrameWork/kernel/services/MigrationService.php
2024-10-08 13:16:57 +03:00

38 lines
946 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace kernel\services;
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use kernel\App;
use kernel\helpers\Debug;
class MigrationService
{
protected ModuleService $moduleService;
public function __construct()
{
$this->moduleService = new ModuleService();
}
/**
* @throws \Exception
*/
public function runAtPath(string $path = ROOT_DIR . '/migrations'): array
{
$path = getConst($path);
try {
$dmr = new DatabaseMigrationRepository(App::$db->capsule->getDatabaseManager(), 'migration');
$m = new Migrator($dmr, App::$db->capsule->getDatabaseManager(), new Filesystem());
return $m->run($path);
} catch (\Exception $e) {
throw new \Exception('Не удалось поднять играции');
}
}
}