admin init command
This commit is contained in:
35
kernel/services/MigrationService.php
Normal file
35
kernel/services/MigrationService.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\services;
|
||||
|
||||
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use kernel\App;
|
||||
|
||||
class MigrationService
|
||||
{
|
||||
protected ModuleService $moduleService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->moduleService = new ModuleService();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function runAtPath(string $path = ROOT_DIR . '/migrations'): array
|
||||
{
|
||||
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('Не удалось поднять играции');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user