mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Added migration of color settings to dark mode
This commit is contained in:
parent
104621841b
commit
f42ff59b43
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CopyColorSettingsForDarkMode extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
DB::table('settings')->insert($newData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$colorSettings = [
|
||||
'app-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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user