diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-14 07:42:16 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-14 07:42:16 +0000 |
| commit | 5e8078fb03c442b9069613e6df3b75d265993bc3 (patch) | |
| tree | 9b763e4f334beee49a603b8c05b6c0287eed8f3a /db | |
| parent | 40bdfaf4415ff9f46e63435fc5e61049649802f2 (diff) | |
fixes #4141
Closes #4141
Merge request studip/studip!2983
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/6.0.4_adjust_cache_types_table.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/db/migrations/6.0.4_adjust_cache_types_table.php b/db/migrations/6.0.4_adjust_cache_types_table.php new file mode 100644 index 0000000..dfe0b27 --- /dev/null +++ b/db/migrations/6.0.4_adjust_cache_types_table.php @@ -0,0 +1,37 @@ +<?php +return new class extends Migration +{ + private const MAPPING = [ + StudipDbCache::class => Studip\Cache\DbCache::class, + StudipFileCache::class => Studip\Cache\FileCache::class, + StudipMemcachedCache::class => Studip\Cache\MemcachedCache::class, + StudipRedisCache::class => Studip\Cache\RedisCache::class, + ]; + + public function description() + { + return 'Replaces the renamed cache classes in table "cache_types"'; + } + + protected function up() + { + foreach (self::MAPPING as $old => $new) { + self::updateCacheTypesTable($old, $new); + } + } + + protected function down() + { + foreach (self::MAPPING as $old => $new) { + self::updateCacheTypesTable($new, $old); + } + } + + private function updateCacheTypesTable(string $old, string $new): void + { + $query = "UPDATE `cache_types` + SET `class_name` = ? + WHERE `class_name` = ?"; + DBManager::get()->execute($query, [$new, $old]); + } +}; |
