From f42ff59b4376493b8c4b30558f017d24a71dd75e Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 28 Jan 2023 17:31:43 +0000 Subject: [PATCH] Added migration of color settings to dark mode --- ...1230_copy_color_settings_for_dark_mode.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 database/migrations/2023_01_28_141230_copy_color_settings_for_dark_mode.php diff --git a/database/migrations/2023_01_28_141230_copy_color_settings_for_dark_mode.php b/database/migrations/2023_01_28_141230_copy_color_settings_for_dark_mode.php new file mode 100644 index 000000000..b72b16162 --- /dev/null +++ b/database/migrations/2023_01_28_141230_copy_color_settings_for_dark_mode.php @@ -0,0 +1,60 @@ +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(); + } +}