[TASK] migration working
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Chrosey\Inventur\Controller;
|
||||
|
||||
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Psr7\Stream;
|
||||
|
||||
class DatabaseController
|
||||
{
|
||||
protected $container;
|
||||
|
||||
function __construct(ContainerInterface $container)
|
||||
{
|
||||
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
function migrate($request, $response, $args)
|
||||
{
|
||||
$capsule = $this->container->get('db')->getDatabaseManager();
|
||||
$repository = new DatabaseMigrationRepository($capsule, 'migrations');
|
||||
if (!$repository->repositoryExists()) {
|
||||
$repository->createRepository();
|
||||
}
|
||||
|
||||
$migrationFilesPath = __DIR__ . '/../../database/migrations/';
|
||||
$fs = new Filesystem();
|
||||
|
||||
$migrator = new Migrator($repository, $capsule, $fs);
|
||||
|
||||
$files = $fs->files($migrationFilesPath);
|
||||
|
||||
$migrator->run($files);
|
||||
}
|
||||
|
||||
function getMigrations()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user