kernel update
This commit is contained in:
@ -36,4 +36,25 @@ class MigrationService
|
||||
}
|
||||
}
|
||||
|
||||
public function rollbackAtPath(string $path): void
|
||||
{
|
||||
$path = getConst($path);
|
||||
try {
|
||||
$filesystem = new Filesystem();
|
||||
$dmr = new DatabaseMigrationRepository(App::$db->capsule->getDatabaseManager(), 'migration');
|
||||
|
||||
$m = new Migrator($dmr, App::$db->capsule->getDatabaseManager(), $filesystem);
|
||||
|
||||
$migrationFiles = $m->getMigrationFiles($path);
|
||||
foreach ($migrationFiles as $name => $migrationFile){
|
||||
$migrationInstance = $filesystem->getRequire($migrationFile);
|
||||
$migrationInstance->migration = $name;
|
||||
$migrationInstance->down();
|
||||
$dmr->delete($migrationInstance);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Не удалось откатить миграции');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user