1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 18:51:40 +02:00

Implement proper update process

If the version in the settings table mismatches the code version, then we return a 503 error for all requests coming through index.php and api.php, while admin.php serves up a form prompting for the database password which will run outstanding migrations.
This commit is contained in:
Toby Zerner
2015-10-19 15:09:54 +10:30
parent 0e06d70b73
commit 23eb4c805b
14 changed files with 290 additions and 55 deletions

View File

@@ -1,90 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Console\Command;
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 UpgradeCommand 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('upgrade')
->setDescription("Run Flarum's upgrade script");
}
/**
* {@inheritdoc}
*/
protected function fire()
{
$this->info('Upgrading 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(base_path('core/migrations'));
foreach ($migrator->getNotes() as $note) {
// $this->info($note);
}
$extensions = $this->container->make('Flarum\Extension\ExtensionManager');
$migrator = $extensions->getMigrator();
foreach ($extensions->getInfo() as $name => $extension) {
if (! $extensions->isEnabled($name)) {
continue;
}
// $this->info('Upgrading extension: '.$extension->name);
$extensions->migrate($name);
foreach ($migrator->getNotes() as $note) {
// $this->info($note);
}
}
}
}

View File

@@ -32,12 +32,9 @@ class Server extends AbstractServer
$console = new Application('Flarum', $app::VERSION);
if (! $app->isInstalled()) {
$app->register('Flarum\Install\InstallServiceProvider');
$console->add($app->make('Flarum\Install\Console\InstallCommand'));
}
$app->register('Flarum\Install\InstallServiceProvider');
$console->add($app->make('Flarum\Install\Console\InstallCommand'));
$console->add($app->make('Flarum\Console\Command\UpgradeCommand'));
$console->add($app->make('Flarum\Console\Command\GenerateExtensionCommand'));
$console->add($app->make('Flarum\Console\Command\GenerateMigrationCommand'));