改进升级方式

This commit is contained in:
Wisp X 2022-08-17 13:06:14 +08:00
parent c46207c278
commit 62809f5300
3 changed files with 9 additions and 8 deletions

View File

@ -115,13 +115,9 @@ class UpgradeService
$version = $this->getVersions()->first()['name']; $version = $this->getVersions()->first()['name'];
Config::query()->where('name', ConfigKey::AppVersion)->update(['value' => $version]); Config::query()->where('name', ConfigKey::AppVersion)->update(['value' => $version]);
// 执行数据库迁移 // 执行数据库迁移
Artisan::call('migrate'); Artisan::call('migrate', ['--seed' => true]);
// 清除配置缓存
Cache::forget('configs');
// 清除缓存 // 清除缓存
Artisan::call('route:clear'); Artisan::call('optimize:clear');
Artisan::call('cache:clear');
Artisan::call('view:clear');
Artisan::call('package:discover'); Artisan::call('package:discover');
} catch (\Throwable $e) { } catch (\Throwable $e) {
Utils::e($e, '升级失败'); Utils::e($e, '升级失败');

View File

@ -18,7 +18,7 @@ use App\Enums\Watermark\Mode;
return [ return [
'app' => [ 'app' => [
ConfigKey::AppName => 'Lsky Pro', ConfigKey::AppName => 'Lsky Pro',
ConfigKey::AppVersion => 'V 2.0.5', ConfigKey::AppVersion => 'V 2.1',
ConfigKey::SiteKeywords => 'Lsky Pro,lsky,兰空图床', ConfigKey::SiteKeywords => 'Lsky Pro,lsky,兰空图床',
ConfigKey::SiteDescription => 'Lsky Pro, Your photo album on the cloud.', ConfigKey::SiteDescription => 'Lsky Pro, Your photo album on the cloud.',
ConfigKey::SiteNotice => '', ConfigKey::SiteNotice => '',

View File

@ -2,6 +2,7 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Models\Config;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
@ -13,6 +14,10 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() public function run()
{ {
// $this->call([]); // 初始化系统默认配置
foreach (config('convention.app') as $key => $value) {
$content = is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : $value;
Config::query()->firstOrCreate(['name' => $key], ['value' => $content]);
}
} }
} }