mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-09-18 18:48:21 +00:00
45d52f27ae
Also updated code to properly import used facades. For #4903
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
$colorSettings = [
|
|
'app-color',
|
|
'app-color-light',
|
|
'bookshelf-color',
|
|
'book-color',
|
|
'chapter-color',
|
|
'page-color',
|
|
'page-draft-color',
|
|
];
|
|
|
|
$existing = DB::table('settings')
|
|
->whereIn('setting_key', $colorSettings)
|
|
->get()->toArray();
|
|
|
|
$newData = [];
|
|
foreach ($existing as $setting) {
|
|
$newSetting = (array) $setting;
|
|
$newSetting['setting_key'] .= '-dark';
|
|
$newData[] = $newSetting;
|
|
|
|
if ($newSetting['setting_key'] === 'app-color-dark') {
|
|
$newSetting['setting_key'] = 'link-color';
|
|
$newData[] = $newSetting;
|
|
$newSetting['setting_key'] = 'link-color-dark';
|
|
$newData[] = $newSetting;
|
|
}
|
|
}
|
|
|
|
DB::table('settings')->insert($newData);
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
$colorSettings = [
|
|
'app-color-dark',
|
|
'link-color',
|
|
'link-color-dark',
|
|
'app-color-light-dark',
|
|
'bookshelf-color-dark',
|
|
'book-color-dark',
|
|
'chapter-color-dark',
|
|
'page-color-dark',
|
|
'page-draft-color-dark',
|
|
];
|
|
|
|
DB::table('settings')
|
|
->whereIn('setting_key', $colorSettings)
|
|
->delete();
|
|
}
|
|
};
|