-
-
Notifications
You must be signed in to change notification settings - Fork 842
/
Copy pathMigrateCommand.php
99 lines (79 loc) · 2.42 KB
/
MigrateCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Database\Console;
use Flarum\Console\AbstractCommand;
use Flarum\Database\Migrator;
use Flarum\Extension\ExtensionManager;
use Flarum\Foundation\Application;
use Flarum\Foundation\Paths;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Container\Container;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Schema\Builder;
class MigrateCommand extends AbstractCommand
{
/**
* @var Container
*/
protected $container;
/**
* @var Paths
*/
protected $paths;
/**
* @param Container $container
* @param Paths $paths
*/
public function __construct(Container $container, Paths $paths)
{
$this->container = $container;
$this->paths = $paths;
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(Builder::class, function ($container) {
return $container->make(ConnectionInterface::class)->getSchemaBuilder();
});
$migrator = $this->container->make(Migrator::class);
$migrator->setOutput($this->output);
$migrator->run(__DIR__.'/../../../migrations');
$extensions = $this->container->make(ExtensionManager::class);
$extensions->getMigrator()->setOutput($this->output);
foreach ($extensions->getEnabledExtensions() as $name => $extension) {
if ($extension->hasMigrations()) {
$this->info('Migrating extension: '.$name);
$extensions->migrate($extension);
}
}
$this->container->make(SettingsRepositoryInterface::class)->set('version', Application::VERSION);
$this->info('Publishing assets...');
$this->container->make('files')->copyDirectory(
$this->paths->vendor.'/components/font-awesome/webfonts',
$this->paths->public.'/assets/fonts'
);
}
}