This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/Console/Command/DatabaseInstallCommand.php

47 lines
1.1 KiB
PHP

<?php
/**
* Holds the migration repository installer command controller.
* @package Sakura
*/
namespace Sakura\Console\Command;
use CLIFramework\Command;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
/**
* Installs the database migration repository.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class DatabaseInstallCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief(): string
{
return 'Create the migration repository';
}
/**
* Does the repository installing.
*/
public function execute(): void
{
$repository = DB::getMigrationRepository();
$migrator = new Migrator($repository, $repository->getConnectionResolver(), new Filesystem);
if ($migrator->repositoryExists()) {
$this->getLogger()->writeln("The migration repository already exists!");
return;
}
$repository->createRepository();
$this->getLogger()->writeln("Created the migration repository!");
}
}