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/DatabaseMigrateCommand.php

40 lines
919 B
PHP

<?php
/**
* Holds the migration command controller.
*
* @package Sakura
*/
namespace Sakura\Console\Command;
use CLIFramework\Command;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Filesystem\Filesystem;
use Sakura\DB;
class DatabaseMigrateCommand extends Command
{
const MIGRATIONS = "database/";
public function brief()
{
return 'Run the database migrations';
}
public function execute()
{
$repository = DB::getMigrationRepository();
$migrator = new Migrator($repository, $repository->getConnectionResolver(), new Filesystem);
if (!$migrator->repositoryExists()) {
$this->getLogger()->writeln("Run 'database-install' first!");
return;
}
$migrator->run(ROOT . self::MIGRATIONS);
foreach ($migrator->getNotes() as $note) {
$this->getLogger()->writeln($note);
}
}
}