52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Utilities\LocalBootstrapMigrator;
|
|
use App\Utilities\SystemDatabaseConfiguration;
|
|
use Illuminate\Console\Command;
|
|
|
|
class UpdateLocalBootstrapDatabase extends Command
|
|
{
|
|
protected $signature = 'local-bootstrap:update';
|
|
|
|
protected $description = '仅为本机临时引导库自动补齐代码所需迁移';
|
|
|
|
public function handle(
|
|
SystemDatabaseConfiguration $configuration,
|
|
LocalBootstrapMigrator $migrator
|
|
): int {
|
|
if (! config('app.installed')) {
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$settings = $configuration->current();
|
|
|
|
if ($settings['mode'] !== 'bootstrap') {
|
|
$this->components->info('当前使用共享系统数据库,本机不会执行数据库迁移。');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
if (
|
|
$settings['connection'] !== 'mysql'
|
|
|| $settings['driver'] !== 'mysql'
|
|
|| $settings['host'] !== 'mysql'
|
|
) {
|
|
$this->components->error('本机引导库配置异常,已拒绝自动迁移。');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$exitCode = $migrator->run();
|
|
|
|
if ($exitCode !== self::SUCCESS) {
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->components->info('本机临时引导库已自动更新。');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|