|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace DoctrineMigrations; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Schema\Schema; |
| 8 | +use Doctrine\Migrations\AbstractMigration; |
| 9 | + |
| 10 | +final class Version20250318102118 extends AbstractMigration |
| 11 | +{ |
| 12 | + private const NEW_SETTINGS = [ |
| 13 | + [ |
| 14 | + 'name' => 'theme_disable_dark_mode', |
| 15 | + 'value' => '0', |
| 16 | + 'type' => 'boolean', |
| 17 | + 'context' => 'theme_settings', |
| 18 | + 'hierarchy' => 30, |
| 19 | + ], |
| 20 | + [ |
| 21 | + 'name' => 'theme_default_mode', |
| 22 | + 'value' => 'light', |
| 23 | + 'type' => 'string', |
| 24 | + 'context' => 'theme_settings', |
| 25 | + 'hierarchy' => 30, |
| 26 | + ], |
| 27 | + [ |
| 28 | + 'name' => 'theme_default_background_color', |
| 29 | + 'value' => '#ffffff', |
| 30 | + 'type' => 'color', |
| 31 | + 'context' => 'theme_settings', |
| 32 | + 'hierarchy' => 30, |
| 33 | + ], |
| 34 | + [ |
| 35 | + 'name' => 'theme_default_link_color', |
| 36 | + 'value' => '#5c70d6', |
| 37 | + 'type' => 'color', |
| 38 | + 'context' => 'theme_settings', |
| 39 | + 'hierarchy' => 30, |
| 40 | + ], |
| 41 | + [ |
| 42 | + 'name' => 'theme_default_link_hover_color', |
| 43 | + 'value' => '#99a6e6', |
| 44 | + 'type' => 'color', |
| 45 | + 'context' => 'theme_settings', |
| 46 | + 'hierarchy' => 30, |
| 47 | + ], |
| 48 | + [ |
| 49 | + 'name' => 'theme_default_dark_background_color', |
| 50 | + 'value' => '#14172e', |
| 51 | + 'type' => 'color', |
| 52 | + 'context' => 'theme_settings', |
| 53 | + 'hierarchy' => 30, |
| 54 | + ], |
| 55 | + [ |
| 56 | + 'name' => 'theme_default_dark_link_color', |
| 57 | + 'value' => '#5d6bc6', |
| 58 | + 'type' => 'color', |
| 59 | + 'context' => 'theme_settings', |
| 60 | + 'hierarchy' => 30, |
| 61 | + ], |
| 62 | + [ |
| 63 | + 'name' => 'theme_default_dark_link_hover_color', |
| 64 | + 'value' => '#7c8bfd', |
| 65 | + 'type' => 'color', |
| 66 | + 'context' => 'theme_settings', |
| 67 | + 'hierarchy' => 30, |
| 68 | + ], |
| 69 | + [ |
| 70 | + 'name' => 'theme_default_secondary_color', |
| 71 | + 'value' => '#f8fafc', |
| 72 | + 'type' => 'color', |
| 73 | + 'context' => 'theme_settings', |
| 74 | + 'hierarchy' => 30, |
| 75 | + ], |
| 76 | + [ |
| 77 | + 'name' => 'theme_default_dark_secondary_color', |
| 78 | + 'value' => '#1c222c', |
| 79 | + 'type' => 'color', |
| 80 | + 'context' => 'theme_settings', |
| 81 | + 'hierarchy' => 30, |
| 82 | + ], |
| 83 | + ]; |
| 84 | + |
| 85 | + private const SETTINGS_TO_UPDATE = [ |
| 86 | + [ |
| 87 | + 'name' => 'theme_default_dark_primary_color', |
| 88 | + 'oldValue' => '#2e59d9', |
| 89 | + 'newValue' => '#1f2347', |
| 90 | + ] |
| 91 | + ]; |
| 92 | + public function getDescription(): string |
| 93 | + { |
| 94 | + return 'New appearance settings'; |
| 95 | + } |
| 96 | + |
| 97 | + public function up(Schema $schema): void |
| 98 | + { |
| 99 | + foreach (self::NEW_SETTINGS as $setting) { |
| 100 | + $this->addSql('INSERT INTO setting (name, value, type, context, hierarchy) VALUES (:name, :value, :type, :context, :hierarchy)', $setting); |
| 101 | + } |
| 102 | + |
| 103 | + foreach (self::SETTINGS_TO_UPDATE as $setting) { |
| 104 | + $this->addSql('UPDATE setting SET value = :newValue WHERE name = :name', $setting); |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + public function down(Schema $schema): void |
| 109 | + { |
| 110 | + foreach (self::NEW_SETTINGS as $setting) { |
| 111 | + $this->addSql('DELETE FROM setting WHERE name = :name', $setting); |
| 112 | + } |
| 113 | + |
| 114 | + foreach (self::SETTINGS_TO_UPDATE as $setting) { |
| 115 | + $this->addSql('UPDATE setting SET value = :oldValue WHERE name = :name', $setting); |
| 116 | + } |
| 117 | + } |
| 118 | +} |
0 commit comments