mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
Live output of migrator notes
This commit is contained in:
parent
2d3f1d9f5c
commit
aab06e0741
|
@ -60,14 +60,12 @@ class MigrateCommand extends AbstractCommand
|
|||
});
|
||||
|
||||
$migrator = $this->container->make('Flarum\Database\Migrator');
|
||||
$migrator->setOutput($this->output);
|
||||
|
||||
$migrator->run(__DIR__.'/../../../migrations');
|
||||
|
||||
foreach ($migrator->getNotes() as $note) {
|
||||
$this->info($note);
|
||||
}
|
||||
|
||||
$extensions = $this->container->make('Flarum\Extension\ExtensionManager');
|
||||
$extensions->getMigrator()->setOutput($this->output);
|
||||
|
||||
foreach ($extensions->getExtensions() as $name => $extension) {
|
||||
if (! $extension->isEnabled()) {
|
||||
|
@ -76,11 +74,7 @@ class MigrateCommand extends AbstractCommand
|
|||
|
||||
$this->info('Migrating extension: '.$name);
|
||||
|
||||
$notes = $extensions->migrate($extension);
|
||||
|
||||
foreach ($notes as $note) {
|
||||
$this->info($note);
|
||||
}
|
||||
$extensions->migrate($extension);
|
||||
}
|
||||
|
||||
$this->container->make('Flarum\Settings\SettingsRepositoryInterface')->set('version', $this->container->version());
|
||||
|
|
|
@ -16,6 +16,7 @@ use Flarum\Extension\Extension;
|
|||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Migrator
|
||||
{
|
||||
|
@ -41,11 +42,11 @@ class Migrator
|
|||
protected $schemaBuilder;
|
||||
|
||||
/**
|
||||
* The notes for the current operation.
|
||||
* The output interface implementation.
|
||||
*
|
||||
* @var array
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $notes = [];
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* Create a new migrator instance.
|
||||
|
@ -246,24 +247,29 @@ class Migrator
|
|||
}
|
||||
|
||||
/**
|
||||
* Raise a note event for the migrator.
|
||||
* Set the output implementation that should be used by the console.
|
||||
*
|
||||
* @param string $message
|
||||
* @param OutputInterface $output
|
||||
* @return $this
|
||||
*/
|
||||
public function setOutput(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a note to the conosle's output.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
protected function note($message)
|
||||
{
|
||||
$this->notes[] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notes for the last operation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotes()
|
||||
{
|
||||
return $this->notes;
|
||||
if ($this->output) {
|
||||
$this->output->writeln($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -236,11 +236,7 @@ class ExtensionManager
|
|||
} else {
|
||||
$this->migrator->reset($migrationDir, $extension);
|
||||
}
|
||||
|
||||
return $this->migrator->getNotes();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user