mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 14:13:37 +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 = $this->container->make('Flarum\Database\Migrator');
|
||||||
|
$migrator->setOutput($this->output);
|
||||||
|
|
||||||
$migrator->run(__DIR__.'/../../../migrations');
|
$migrator->run(__DIR__.'/../../../migrations');
|
||||||
|
|
||||||
foreach ($migrator->getNotes() as $note) {
|
|
||||||
$this->info($note);
|
|
||||||
}
|
|
||||||
|
|
||||||
$extensions = $this->container->make('Flarum\Extension\ExtensionManager');
|
$extensions = $this->container->make('Flarum\Extension\ExtensionManager');
|
||||||
|
$extensions->getMigrator()->setOutput($this->output);
|
||||||
|
|
||||||
foreach ($extensions->getExtensions() as $name => $extension) {
|
foreach ($extensions->getExtensions() as $name => $extension) {
|
||||||
if (! $extension->isEnabled()) {
|
if (! $extension->isEnabled()) {
|
||||||
|
@ -76,11 +74,7 @@ class MigrateCommand extends AbstractCommand
|
||||||
|
|
||||||
$this->info('Migrating extension: '.$name);
|
$this->info('Migrating extension: '.$name);
|
||||||
|
|
||||||
$notes = $extensions->migrate($extension);
|
$extensions->migrate($extension);
|
||||||
|
|
||||||
foreach ($notes as $note) {
|
|
||||||
$this->info($note);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->container->make('Flarum\Settings\SettingsRepositoryInterface')->set('version', $this->container->version());
|
$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\ConnectionInterface;
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class Migrator
|
class Migrator
|
||||||
{
|
{
|
||||||
|
@ -41,11 +42,11 @@ class Migrator
|
||||||
protected $schemaBuilder;
|
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.
|
* 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 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
|
* @param string $message
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function note($message)
|
protected function note($message)
|
||||||
{
|
{
|
||||||
$this->notes[] = $message;
|
if ($this->output) {
|
||||||
|
$this->output->writeln($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notes for the last operation.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getNotes()
|
|
||||||
{
|
|
||||||
return $this->notes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -236,11 +236,7 @@ class ExtensionManager
|
||||||
} else {
|
} else {
|
||||||
$this->migrator->reset($migrationDir, $extension);
|
$this->migrator->reset($migrationDir, $extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->migrator->getNotes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user