* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Flarum\Update\Console; use Flarum\Console\Command\AbstractCommand; use Illuminate\Contracts\Container\Container; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends AbstractCommand { /** * @var Container */ protected $container; /** * @param Container $container */ public function __construct(Container $container) { $this->container = $container; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('migrate') ->setDescription("Run outstanding migrations."); } /** * {@inheritdoc} */ protected function fire() { $this->info('Migrating Flarum...'); $this->upgrade(); $this->info('DONE.'); } public function upgrade() { $this->container->bind('Illuminate\Database\Schema\Builder', function ($container) { return $container->make('Illuminate\Database\ConnectionInterface')->getSchemaBuilder(); }); $migrator = $this->container->make('Flarum\Database\Migrator'); $migrator->run(__DIR__.'/../../../migrations'); foreach ($migrator->getNotes() as $note) { $this->info($note); } $extensions = $this->container->make('Flarum\Extension\ExtensionManager'); $migrator = $extensions->getMigrator(); foreach ($extensions->getExtensions() as $name => $extension) { if (! $extension->isEnabled()) { continue; } $this->info('Migrating extension: '.$name); $extensions->migrate($extension); foreach ($migrator->getNotes() as $note) { $this->info($note); } } $this->container->make('Flarum\Settings\SettingsRepositoryInterface')->set('version', $this->container->version()); } }